aboutsummaryrefslogtreecommitdiff
path: root/doc/sphinx
diff options
context:
space:
mode:
Diffstat (limited to 'doc/sphinx')
-rw-r--r--doc/sphinx/_static/coqdoc.css4
-rw-r--r--doc/sphinx/_static/diffs-show-proof.pngbin0 -> 13641 bytes
-rw-r--r--doc/sphinx/addendum/extraction.rst112
-rw-r--r--doc/sphinx/addendum/generalized-rewriting.rst76
-rw-r--r--doc/sphinx/addendum/implicit-coercions.rst64
-rw-r--r--doc/sphinx/addendum/micromega.rst95
-rw-r--r--doc/sphinx/addendum/miscellaneous-extensions.rst6
-rw-r--r--doc/sphinx/addendum/nsatz.rst78
-rw-r--r--doc/sphinx/addendum/omega.rst6
-rw-r--r--doc/sphinx/addendum/program.rst134
-rw-r--r--doc/sphinx/addendum/ring.rst149
-rw-r--r--doc/sphinx/addendum/type-classes.rst215
-rw-r--r--doc/sphinx/addendum/universe-polymorphism.rst27
-rw-r--r--doc/sphinx/appendix/history-and-changes/index.rst6
-rw-r--r--doc/sphinx/changes.rst493
-rwxr-xr-xdoc/sphinx/conf.py2
-rw-r--r--doc/sphinx/history.rst34
-rw-r--r--doc/sphinx/introduction.rst30
-rw-r--r--doc/sphinx/language/core/assumptions.rst10
-rw-r--r--doc/sphinx/language/core/basic.rst20
-rw-r--r--doc/sphinx/language/core/coinductive.rst10
-rw-r--r--doc/sphinx/language/core/definitions.rst14
-rw-r--r--doc/sphinx/language/core/index.rst2
-rw-r--r--doc/sphinx/language/core/inductive.rst26
-rw-r--r--doc/sphinx/language/core/modules.rst8
-rw-r--r--doc/sphinx/language/core/primitive.rst28
-rw-r--r--doc/sphinx/language/core/records.rst23
-rw-r--r--doc/sphinx/language/core/sections.rst2
-rw-r--r--doc/sphinx/language/core/variants.rst1
-rw-r--r--doc/sphinx/language/extensions/arguments-command.rst9
-rw-r--r--doc/sphinx/language/extensions/canonical.rst4
-rw-r--r--doc/sphinx/language/extensions/evars.rst2
-rw-r--r--doc/sphinx/language/extensions/implicit-arguments.rst2
-rw-r--r--doc/sphinx/language/extensions/index.rst2
-rw-r--r--doc/sphinx/language/extensions/match.rst39
-rw-r--r--doc/sphinx/practical-tools/coq-commands.rst20
-rw-r--r--doc/sphinx/practical-tools/coqide.rst18
-rw-r--r--doc/sphinx/practical-tools/utilities.rst48
-rw-r--r--doc/sphinx/proof-engine/ltac.rst29
-rw-r--r--doc/sphinx/proof-engine/ltac2.rst90
-rw-r--r--doc/sphinx/proof-engine/proof-handling.rst890
-rw-r--r--doc/sphinx/proof-engine/ssreflect-proof-language.rst12
-rw-r--r--doc/sphinx/proof-engine/tactics.rst2121
-rw-r--r--doc/sphinx/proof-engine/vernacular-commands.rst38
-rw-r--r--doc/sphinx/proofs/automatic-tactics/auto.rst672
-rw-r--r--doc/sphinx/proofs/automatic-tactics/index.rst10
-rw-r--r--doc/sphinx/proofs/automatic-tactics/logic.rst294
-rw-r--r--doc/sphinx/proofs/creating-tactics/index.rst10
-rw-r--r--doc/sphinx/proofs/writing-proofs/index.rst11
-rw-r--r--doc/sphinx/proofs/writing-proofs/proof-mode.rst1037
-rw-r--r--doc/sphinx/proofs/writing-proofs/rewriting.rst857
-rw-r--r--doc/sphinx/user-extensions/proof-schemes.rst83
-rw-r--r--doc/sphinx/user-extensions/syntax-extensions.rst505
-rw-r--r--doc/sphinx/using/libraries/funind.rst94
-rw-r--r--doc/sphinx/using/libraries/index.rst6
-rw-r--r--doc/sphinx/using/libraries/writing.rst10
-rw-r--r--doc/sphinx/using/tools/coqdoc.rst6
-rw-r--r--doc/sphinx/using/tools/index.rst8
58 files changed, 4544 insertions, 4058 deletions
diff --git a/doc/sphinx/_static/coqdoc.css b/doc/sphinx/_static/coqdoc.css
index 32cb0a7a15..c0b4ee4a9f 100644
--- a/doc/sphinx/_static/coqdoc.css
+++ b/doc/sphinx/_static/coqdoc.css
@@ -66,3 +66,7 @@
.coqdoc-tactic {
font-weight: bold;
}
+
+.smallcaps {
+ font-variant: small-caps;
+}
diff --git a/doc/sphinx/_static/diffs-show-proof.png b/doc/sphinx/_static/diffs-show-proof.png
new file mode 100644
index 0000000000..62bd9cccd0
--- /dev/null
+++ b/doc/sphinx/_static/diffs-show-proof.png
Binary files differ
diff --git a/doc/sphinx/addendum/extraction.rst b/doc/sphinx/addendum/extraction.rst
index c2249b8e57..96e115fc3d 100644
--- a/doc/sphinx/addendum/extraction.rst
+++ b/doc/sphinx/addendum/extraction.rst
@@ -16,7 +16,7 @@ Before using any of the commands or options described in this chapter,
the extraction framework should first be loaded explicitly
via ``Require Extraction``, or via the more robust
``From Coq Require Extraction``.
-Note that in earlier versions of Coq, these commands and options were
+Note that in earlier versions of |Coq|, these commands and options were
directly available without any preliminary ``Require``.
.. coqtop:: in
@@ -72,10 +72,10 @@ produce one monolithic file or one file per |Coq| library.
Recursive extraction of all the mentioned objects and all
their dependencies, just as :n:`Extraction @string {+ @qualid }`,
but instead of producing one monolithic file, this command splits
- the produced code in separate ML files, one per corresponding Coq
+ the produced code in separate ML files, one per corresponding |Coq|
``.v`` file. This command is hence quite similar to
:cmd:`Recursive Extraction Library`, except that only the needed
- parts of Coq libraries are extracted instead of the whole.
+ parts of |Coq| libraries are extracted instead of the whole.
The naming convention in case of name clash is the same one as
:cmd:`Extraction Library`: identifiers are here renamed using prefixes
``coq_`` or ``Coq_``.
@@ -99,10 +99,18 @@ Extraction Options
Setting the target language
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. cmd:: Extraction Language {| OCaml | Haskell | Scheme | JSON }
+.. cmd:: Extraction Language @language
:name: Extraction Language
- The ability to fix target language is the first and more important
+ .. insertprodn language language
+
+ .. prodn::
+ language ::= OCaml
+ | Haskell
+ | Scheme
+ | JSON
+
+ The ability to fix target language is the first and most important
of the extraction options. Default is ``OCaml``.
The JSON output is mostly for development or debugging:
@@ -138,7 +146,7 @@ and commands:
Default is on. This controls all type-preserving optimizations made on
the ML terms (mostly reduction of dummy beta/iota redexes, but also
simplifications on Cases, etc). Turn this flag off if you want a
- ML term as close as possible to the Coq term.
+ ML term as close as possible to the |Coq| term.
.. flag:: Extraction Conservative Types
@@ -215,14 +223,15 @@ code elimination performed during extraction, in a way which
is independent but complementary to the main elimination
principles of extraction (logical parts and types).
-.. cmd:: Extraction Implicit @qualid [ {+ @ident } ]
+.. cmd:: Extraction Implicit @qualid [ {* {| @ident | @integer } } ]
- This experimental command allows declaring some arguments of
- :token:`qualid` as implicit, i.e. useless in extracted code and hence to
- be removed by extraction. Here :token:`qualid` can be any function or
- inductive constructor, and the given :token:`ident` are the names of
- the concerned arguments. In fact, an argument can also be referred
- by a number indicating its position, starting from 1.
+ Declares some arguments of
+ :token:`qualid` as implicit, meaning that they are useless in extracted code.
+ The extracted code will omit these arguments.
+ Here :token:`qualid` can be
+ any function or inductive constructor, and the :token:`ident`\s are
+ the names of the useless arguments. Arguments can can also be
+ identified positionally by :token:`integer`\s starting from 1.
When an actual extraction takes place, an error is normally raised if the
:cmd:`Extraction Implicit` declarations cannot be honored, that is
@@ -254,12 +263,24 @@ a closed term, and of course the system cannot guess the program which
realizes an axiom. Therefore, it is possible to tell the system
what ML term corresponds to a given axiom.
-.. cmd:: Extract Constant @qualid => @string
+.. cmd:: Extract Constant @qualid {* @string__tv } => {| @ident | @string }
Give an ML extraction for the given constant.
- The :token:`string` may be an identifier or a quoted string.
-.. cmd:: Extract Inlined Constant @qualid => @string
+ :n:`@string__tv`
+ If the type scheme axiom is an arity (a sequence of products followed
+ by a sort), then some type
+ variables have to be given (as quoted strings).
+
+ The number of type variables is checked by the system. For example:
+
+ .. coqtop:: in
+
+ Axiom Y : Set -> Set -> Set.
+ Extract Constant Y "'a" "'b" => " 'a * 'b ".
+
+
+.. cmd:: Extract Inlined Constant @qualid => {| @ident | @string }
Same as the previous one, except that the given ML terms will
be inlined everywhere instead of being declared via a ``let``.
@@ -282,20 +303,6 @@ what ML term corresponds to a given axiom.
Extract Constant X => "int".
Extract Constant x => "0".
-Notice that in the case of type scheme axiom (i.e. whose type is an
-arity, that is a sequence of product finished by a sort), then some type
-variables have to be given (as quoted strings). The syntax is then:
-
-.. cmdv:: Extract Constant @qualid {+ @string } => @string
- :undocumented:
-
-The number of type variables is checked by the system. For example:
-
-.. coqtop:: in
-
- Axiom Y : Set -> Set -> Set.
- Extract Constant Y "'a" "'b" => " 'a * 'b ".
-
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
has no computational content and hence will not appear in extracted
@@ -316,36 +323,35 @@ 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 the |Coq| one. The syntax is the following:
-.. cmd:: Extract Inductive @qualid => @string__1 [ {+ @string } ]
+.. cmd:: Extract Inductive @qualid => {| @ident | @string } [ {* {| @ident | @string } } ] {? @string__match }
Give an ML extraction for the given inductive type. You must specify
- extractions for the type itself (:n:`@string__1`) and all its
- constructors (all the :n:`@string` between square brackets). In this form,
+ extractions for the type itself (the initial :n:`{| @ident | @string }`) and all its
+ constructors (the :n:`[ {* {| @ident | @string } } ]`). In this form,
the ML extraction must be an ML inductive datatype, and the native
pattern matching of the language will be used.
- When :n:`@string__1` matches the name of the type of characters or strings
+ When the initial :n:`{| @ident | @string }` matches the name of the type of characters or strings
(``char`` and ``string`` for OCaml, ``Prelude.Char`` and ``Prelude.String``
for Haskell), extraction of literals is handled in a specialized way, so as
to generate literals in the target language. This feature requires the type
designated by :n:`@qualid` to be registered as the standard char or string type,
using the :cmd:`Register` command.
-.. cmdv:: Extract Inductive @qualid => @string [ {+ @string } ] @string
-
- Same as before, with a final extra :token:`string` that indicates how to
- perform pattern matching over this inductive type. In this form,
- the ML extraction could be an arbitrary type.
- For an inductive type with :math:`k` constructors, the function used to
- emulate the pattern matching should expect :math:`k+1` arguments, first the :math:`k`
- 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
- 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 :g:`nat`
- into |OCaml| ``int``, the code to be provided has type:
- ``(unit->'a)->(int->'a)->int->'a``.
+ :n:`@string__match`
+ Indicates how to
+ perform pattern matching over this inductive type. In this form,
+ the ML extraction could be an arbitrary type.
+ For an inductive type with :math:`k` constructors, the function used to
+ emulate the pattern matching should expect :math:`k+1` arguments, first the :math:`k`
+ 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
+ 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 :g:`nat`
+ 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:
@@ -434,7 +440,7 @@ Additional settings
Controls which optimizations are used during extraction, providing a finer-grained
control than :flag:`Extraction Optimize`. The bits of :token:`natural` are used as a bit mask.
- Keeping an option off keeps the extracted ML more similar to the Coq term.
+ Keeping an option off keeps the extracted ML more similar to the |Coq| term.
Values are:
+-----+-------+----------------------------------------------------------------+
@@ -465,7 +471,7 @@ Additional settings
.. flag:: Extraction TypeExpand
- If set, fully expand Coq types in ML. See the Coq source code to learn more.
+ If set, fully expand |Coq| types in ML. See the |Coq| source code to learn more.
Differences between |Coq| and ML type systems
----------------------------------------------
@@ -515,7 +521,7 @@ In |OCaml|, we must cast any argument of the constructor dummy
Even with those unsafe castings, you should never get error like
``segmentation fault``. In fact even if your program may seem
ill-typed to the |OCaml| type checker, it can't go wrong : it comes
-from a Coq well-typed terms, so for example inductive types will always
+from a |Coq| well-typed terms, so for example inductive types will always
have the correct number of arguments, etc. Of course, when launching
manually some extracted function, you should apply it to arguments
of the right shape (from the |Coq| point-of-view).
@@ -524,7 +530,7 @@ More details about the correctness of the extracted programs can be
found in :cite:`Let02`.
We have to say, though, that in most "realistic" programs, these problems do not
-occur. For example all the programs of Coq library are accepted by the |OCaml|
+occur. For example all the programs of |Coq| library are accepted by the |OCaml|
type checker without any ``Obj.magic`` (see examples below).
Some examples
diff --git a/doc/sphinx/addendum/generalized-rewriting.rst b/doc/sphinx/addendum/generalized-rewriting.rst
index 759f630b85..407a38378f 100644
--- a/doc/sphinx/addendum/generalized-rewriting.rst
+++ b/doc/sphinx/addendum/generalized-rewriting.rst
@@ -35,7 +35,7 @@ the previous implementation in several ways:
the new implementation, if one provides the proper morphisms. Again,
most of the work is handled in the tactics.
+ First-class morphisms and signatures. Signatures and morphisms are
- ordinary Coq terms, hence they can be manipulated inside Coq, put
+ ordinary |Coq| terms, hence they can be manipulated inside |Coq|, put
inside structures and lemmas about them can be proved inside the
system. Higher-order morphisms are also allowed.
+ Performance. The implementation is based on a depth-first search for
@@ -103,7 +103,7 @@ argument.
Morphisms can also be contravariant in one or more of their arguments.
A morphism is contravariant on an argument associated to the relation
instance :math:`R` if it is covariant on the same argument when the inverse
-relation :math:`R^{−1}` (``inverse R`` in Coq) is considered. The special arrow ``-->``
+relation :math:`R^{−1}` (``inverse R`` in |Coq|) is considered. The special arrow ``-->``
is used in signatures for contravariant morphisms.
Functions having arguments related by symmetric relations instances
@@ -144,7 +144,7 @@ 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
+equality in |Coq| can also work with the registered relations. The exact
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
@@ -170,10 +170,17 @@ compatibility constraints.
Adding new relations and morphisms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. cmd:: Add Parametric Relation {* @binder } : (A t1 ... tn) (Aeq t′1 ... t′m) {? reflexivity proved by @term} {? symmetry proved by @term} {? transitivity proved by @term} as @ident
+.. cmd:: Add Parametric Relation {* @binder } : @one_term__A @one_term__Aeq {? reflexivity proved by @one_term } {? symmetry proved by @one_term } {? transitivity proved by @one_term } as @ident
- This command declares a parametric relation :g:`Aeq: forall (y1 : β1 ... ym : βm)`,
- :g:`relation (A t1 ... tn)` over :g:`(A : αi -> ... αn -> Type)`.
+ Declares a parametric relation of :n:`@one_term__A`, which is a `Type`, say `T`, with
+ :n:`@one_term__Aeq`, which is a relation on `T`, i.e. of type `(T -> T -> Prop)`.
+ Thus, if :n:`@one_term__A` is
+ :n:`A: forall α__1 … α__n, Type` then :n:`@one_term__Aeq` is
+ :n:`Aeq: forall α__1 … α__n, (A α__1 … α__n) -> (A α__1 … α__n) -> Prop`,
+ or equivalently, :n:`Aeq: forall α__1 … α__n, relation (A α__1 … α__n)`.
+
+ :n:`@one_term__A` and :n:`@one_term__Aeq` must be typeable under the context
+ :token:`binder`\s. In practice, the :token:`binder`\s usually correspond to the :n:`α`\s
The final :token:`ident` gives a unique name to the morphism and it is used
by the command to generate fresh names for automatically provided
@@ -189,16 +196,16 @@ Adding new relations and morphisms
To use this command, you need to first import the module ``Setoid`` using
the command ``Require Import Setoid``.
-.. cmd:: Add Relation
+.. cmd:: Add Relation @one_term @one_term {? reflexivity proved by @one_term } {? symmetry proved by @one_term } {? transitivity proved by @one_term } as @ident
- In case the carrier and relations are not parametric, one can use this command
+ If the carrier and relations are not parametric, 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)`.
+ :g:`reflexive (A t1 … tn) (Aeq t′ 1 … t′ n)`.
Each proof may refer to the introduced variables as well.
.. example:: Parametric relation
@@ -219,10 +226,10 @@ 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 {* @binder } : (@ident {+ @term__1}) with signature @term__2 as @ident
+.. cmd:: Add Parametric Morphism {* @binder } : @one_term with signature @term as @ident
- This command declares a parametric morphism :n:`@ident {+ @term__1}` of
- signature :n:`@term__2`. The final identifier :token:`ident` gives a unique
+ Declares a parametric morphism :n:`@one_term` of
+ signature :n:`@term`. The final identifier :token:`ident` gives a unique
name to the morphism and it is used as the base name of the typeclass
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
@@ -525,12 +532,13 @@ counterparts when the relation involved is not Leibniz equality.
Notice, however, that using the prefixed tactics it is possible to
pass additional arguments such as ``using relation``.
-.. tacv:: setoid_reflexivity
- setoid_symmetry {? in @ident}
- setoid_transitivity
- setoid_rewrite {? @orientation} @term {? at @occurrences} {? in @ident}
- setoid_replace @term with @term {? using relation @term} {? in @ident} {? by @ltac_expr3}
- :name: setoid_reflexivity; setoid_symmetry; setoid_transitivity; setoid_rewrite; setoid_replace
+.. tacn:: setoid_reflexivity
+ setoid_symmetry {? in @ident }
+ setoid_transitivity @one_term
+ setoid_rewrite {? {| -> | <- } } @one_term {? with @bindings } {? at @occurrences } {? in @ident }
+ setoid_rewrite {? {| -> | <- } } @one_term {? with @bindings } in @ident at @occurrences
+ setoid_replace @one_term with @one_term {? using relation @one_term } {? in @ident } {? at {+ @int_or_var } } {? by @ltac_expr3 }
+ :name: setoid_reflexivity; setoid_symmetry; setoid_transitivity; setoid_rewrite; _; setoid_replace
The ``using relation`` arguments cannot be passed to the unprefixed form.
The latter argument tells the tactic what parametric relation should
@@ -553,34 +561,35 @@ system up to user defined equalities.
Printing relations and morphisms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. cmd:: Print Instances
+Use the :cmd:`Print Instances` command with the class names ``Reflexive``, ``Symmetric``
+or ``Transitive`` to print registered reflexive, symmetric or transitive relations and
+with the class name ``Proper`` to print morphisms.
- 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.
+When rewriting tactics refuse
+to replace a term in a context because the latter is not a composition
+of morphisms, this command can be useful to understand
+what additional morphisms should be registered.
.. _deprecated_syntax_for_generalized_rewriting:
Deprecated syntax and backward incompatibilities
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. cmd:: Add Setoid @qualid__1 @qualid__2 @qualid__3 as @ident
+.. cmd:: Add Setoid @one_term__carrier @one_term__congruence @one_term__proofs as @ident
This command for declaring setoids and morphisms is also accepted due
to backward compatibility reasons.
- Here :n:`@qualid__2` is a congruence relation without parameters, :n:`@qualid__1` is its carrier
- and :n:`@qualid__3` is an object of type (:n:`Setoid_Theory @qualid__1 @qualid__2`) (i.e. a record
+ Here :n:`@one_term__congruence` is a congruence relation without parameters,
+ :n:`@one_term__carrier` is its carrier and :n:`@one_term__proofs` is an object
+ of type (:n:`Setoid_Theory @one_term__carrier @one_term__congruence`) (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 @ident : @ident
- :name: Add Morphism
+.. cmd:: Add Morphism @one_term : @ident
+ Add Morphism @one_term with signature @term as @ident
+ :name: Add Morphism; _
This command is restricted to the declaration of morphisms
without parameters. It is not fully backward compatible since the
@@ -590,11 +599,10 @@ Deprecated syntax and backward incompatibilities
bi-implication in place of a simple implication. In practice, porting
an old development to the new semantics is usually quite simple.
-.. cmd:: Declare Morphism @ident : @ident
+.. cmd:: Declare Morphism @one_term : @ident
:name: Declare Morphism
- This commands is to be used in a module type to declare a parameter that
- is a morphism.
+ Declares a parameter in a module type that is a morphism.
Notice that several limitations of the old implementation have been
lifted. In particular, it is now possible to declare several relations
diff --git a/doc/sphinx/addendum/implicit-coercions.rst b/doc/sphinx/addendum/implicit-coercions.rst
index dafa510ade..b81212ad0d 100644
--- a/doc/sphinx/addendum/implicit-coercions.rst
+++ b/doc/sphinx/addendum/implicit-coercions.rst
@@ -125,10 +125,16 @@ term consists of the successive application of its coercions.
Declaring Coercions
-------------------------
-.. cmd:: Coercion @qualid : @class >-> @class
+.. cmd:: Coercion @reference : @class >-> @class
+ Coercion @ident {? @univ_decl } @def_body
- Declares the construction denoted by :token:`qualid` as a coercion between
- the two given classes.
+ :name: Coercion; _
+
+ The first form declares the construction denoted by :token:`reference` as a coercion between
+ the two given classes. The second form defines :token:`ident`
+ just like :cmd:`Definition` :n:`@ident {? @univ_decl } @def_body`
+ and then declares :token:`ident` as a coercion between it source and its target.
+ Both forms support the :attr:`local` attribute, which makes the coercion local to the current section.
.. exn:: @qualid not declared.
:undocumented:
@@ -174,21 +180,6 @@ Declaring Coercions
circular. When a new circular coercion path is not convertible with the
identity function, it will be reported as ambiguous.
- .. cmdv:: Local Coercion @qualid : @class >-> @class
-
- Declares the construction denoted by :token:`qualid` as a coercion local to
- the current section.
-
- .. cmdv:: Coercion @ident := @term {? @type }
-
- This defines :token:`ident` just like :n:`Definition @ident := term {? @type }`,
- and then declares :token:`ident` as a coercion between it source and its target.
-
- .. cmdv:: Local Coercion @ident := @term {? @type }
-
- This defines :token:`ident` just like :n:`Let @ident := @term {? @type }`,
- and then declares :token:`ident` as a coercion between it source and its target.
-
Some objects can be declared as coercions when they are defined.
This applies to :ref:`assumptions<gallina-assumptions>` and
constructors of :ref:`inductive types and record fields<gallina-inductive-definitions>`.
@@ -205,13 +196,11 @@ Use :n:`:>` instead of :n:`:` before the
function with type :g:`forall (x₁:T₁)..(xₙ:Tₙ)(y:C x₁..xₙ),D t₁..tₘ`,
and we declare it as an identity coercion between ``C`` and ``D``.
+ This command supports the :attr:`local` attribute, which makes the coercion local to the current section.
+
.. exn:: @class must be a transparent constant.
:undocumented:
- .. cmdv:: Local Identity Coercion @ident : @ident >-> @ident
-
- Same as :cmd:`Identity Coercion` but locally to the current section.
-
.. cmd:: SubClass @ident_decl @def_body
:name: SubClass
@@ -223,9 +212,7 @@ Use :n:`:>` instead of :n:`:` before the
:n:`Definition @ident := @type.`
:n:`Identity Coercion Id_@ident_@ident' : @ident >-> @ident'`.
- .. cmdv:: Local SubClass @ident_decl @def_body
-
- Same as before but locally to the current section.
+ This command supports the :attr:`local` attribute, which makes the coercion local to the current section.
Displaying Available Coercions
@@ -268,24 +255,15 @@ Classes as Records
.. index:: :> (coercion)
-We allow the definition of *Structures with Inheritance* (or classes as records)
-by extending the existing :cmd:`Record` macro. Its new syntax is:
-
-.. cmdv:: {| Record | Structure } {? >} @ident {* @binder } : @sort := {? @ident} { {+; @ident :{? >} @term } }
-
- The first identifier :token:`ident` is the name of the defined record and
- :token:`sort` is its type. The optional identifier after ``:=`` is the name
- of the constructor (it will be :n:`Build_@ident` if not given).
- The other identifiers are the names of the fields, and :token:`term`
- are their respective types. If ``:>`` is used instead of ``:`` in
- the declaration of a field, then the name of this field is automatically
- declared as a coercion from the record name to the class of this
- field type. Note that the fields always verify the uniform
- inheritance condition. If the optional ``>`` is given before the
- record name, then the constructor name is automatically declared as
- a coercion from the class of the last field type to the record name
- (this may fail if the uniform inheritance condition is not
- satisfied).
+*Structures with Inheritance* may be defined using the :cmd:`Record` command.
+
+Use `>` before the record name to declare the constructor name as
+a coercion from the class of the last field type to the record name
+(this may fail if the uniform inheritance condition is not
+satisfied). See :token:`record_definition`.
+
+Use `:>` in the field type to declare the field as a coercion from the record name
+to the class of the field type. See :token:`of_type`.
Coercions and Sections
----------------------
diff --git a/doc/sphinx/addendum/micromega.rst b/doc/sphinx/addendum/micromega.rst
index ba5bac6489..2c7b637a42 100644
--- a/doc/sphinx/addendum/micromega.rst
+++ b/doc/sphinx/addendum/micromega.rst
@@ -1,6 +1,6 @@
.. _micromega:
-Micromega: tactics for solving arithmetic goals over ordered rings
+Micromega: solvers for arithmetic goals over ordered rings
==================================================================
:Authors: Frédéric Besson and Evgeny Makarov
@@ -25,8 +25,8 @@ tactics for solving arithmetic goals over :math:`\mathbb{Q}`,
``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` [#csdp]_. Note that the `csdp` driver is
- generating a *proof cache* which makes it possible to rerun scripts
+ driver to the external prover `csdp` [#csdp]_. Note that the `csdp` driver
+ generates a *proof cache* which makes it possible to rerun scripts
even without `csdp`.
.. flag:: Simplex
@@ -250,7 +250,7 @@ proof by abstracting monomials by variables.
`psatz`: a proof procedure for non-linear arithmetic
----------------------------------------------------
-.. tacn:: psatz
+.. tacn:: psatz @one_term {? @int_or_var }
:name: psatz
This tactic explores the *Cone* by increasing degrees – hence the
@@ -260,7 +260,7 @@ proof by abstracting monomials by variables.
that might miss a refutation.
To illustrate the working of the tactic, consider we wish to prove the
- following Coq goal:
+ following |Coq| goal:
.. needs csdp
.. coqdoc::
@@ -283,60 +283,103 @@ obtain :math:`-1`. By Theorem :ref:`Psatz <psatz_thm>`, the goal is valid.
.. tacn:: zify
:name: zify
- This tactic is internally called by :tacn:`lia` to support additional types e.g., :g:`nat`, :g:`positive` and :g:`N`.
- By requiring the module ``ZifyBool``, the boolean type :g:`bool` and some comparison operators are also supported.
+ This tactic is internally called by :tacn:`lia` to support additional types, e.g., :g:`nat`, :g:`positive` and :g:`N`.
+ Additional support is provided by the following modules:
+
+ + For boolean operators (e.g., :g:`Nat.leb`), require the module :g:`ZifyBool`.
+ + For comparison operators (e.g., :g:`Z.compare`), require the module :g:`ZifyComparison`.
+ + For native 63 bit integers, require the module :g:`ZifyInt63`.
+
:tacn:`zify` can also be extended by rebinding the tactics `Zify.zify_pre_hook` and `Zify.zify_post_hook` that are
respectively run in the first and the last steps of :tacn:`zify`.
+ To support :g:`Z.div` and :g:`Z.modulo`: ``Ltac Zify.zify_post_hook ::= Z.div_mod_to_equations``.
+ To support :g:`Z.quot` and :g:`Z.rem`: ``Ltac Zify.zify_post_hook ::= Z.quot_rem_to_equations``.
- + To support :g:`Z.div`, :g:`Z.modulo`, :g:`Z.quot`, and :g:`Z.rem`: ``Ltac Zify.zify_post_hook ::= Z.to_euclidean_division_equations``.
+ + To support :g:`Z.div`, :g:`Z.modulo`, :g:`Z.quot` and :g:`Z.rem`: either ``Ltac Zify.zify_post_hook ::= Z.to_euclidean_division_equations`` or ``Ltac Zify.zify_convert_to_euclidean_division_equations_flag ::= constr:(true)``.
The :tacn:`zify` tactic can be extended with new types and operators by declaring and registering new typeclass instances using the following commands.
The typeclass declarations can be found in the module ``ZifyClasses`` and the default instances can be found in the module ``ZifyInst``.
-.. cmd:: Add Zify {| InjTyp | BinOp | UnOp |CstOp | BinRel | UnOpSpec | BinOpSpec } @qualid
+.. cmd:: Add Zify @add_zify @one_term
- This command registers an instance of one of the typeclasses among ``InjTyp``, ``BinOp``, ``UnOp``, ``CstOp``, ``BinRel``,
- ``UnOpSpec``, ``BinOpSpec``.
+ .. insertprodn add_zify add_zify
+
+ .. prodn::
+ add_zify ::= {| InjTyp | BinOp | UnOp | CstOp | BinRel | UnOpSpec | BinOpSpec }
+ | {| PropOp | PropBinOp | PropUOp | Saturate }
-.. cmd:: Show Zify {| InjTyp | BinOp | UnOp |CstOp | BinRel | UnOpSpec | BinOpSpec }
+ Registers an instance of the specified typeclass.
- The command prints the typeclass instances of one the typeclasses
- among ``InjTyp``, ``BinOp``, ``UnOp``, ``CstOp``, ``BinRel``,
- ``UnOpSpec``, ``BinOpSpec``. For instance, :cmd:`Show Zify` ``InjTyp``
+.. cmd:: Show Zify @show_zify
+
+ .. insertprodn show_zify show_zify
+
+ .. prodn::
+ show_zify ::= {| InjTyp | BinOp | UnOp | CstOp | BinRel | UnOpSpec | BinOpSpec | Spec }
+
+ Prints instances for the specified typeclass. For instance, :cmd:`Show Zify` ``InjTyp``
prints the list of types that supported by :tacn:`zify` i.e.,
:g:`Z`, :g:`nat`, :g:`positive` and :g:`N`.
.. cmd:: Show Zify Spec
.. deprecated:: 8.13
- Use instead either :cmd:`Show Zify` ``UnOpSpec`` or :cmd:`Show Zify` ``BinOpSpec``.
+ Use :cmd:`Show Zify` ``UnOpSpec`` or :cmd:`Show Zify` ``BinOpSpec`` instead.
+
+.. cmd:: Add InjTyp @one_term
+
+ .. deprecated:: 8.13
+ Use :cmd:`Add Zify` ``InjTyp`` instead.
+
+.. cmd:: Add BinOp @one_term
+
+ .. deprecated:: 8.13
+ Use :cmd:`Add Zify` ``BinOp`` instead.
+
+.. cmd:: Add BinOpSpec @one_term
+
+ .. deprecated:: 8.13
+ Use :cmd:`Add Zify` ``BinOpSpec`` instead.
+
+.. cmd:: Add UnOp @one_term
+
+ .. deprecated:: 8.13
+ Use :cmd:`Add Zify` ``UnOp`` instead.
+
+.. cmd:: Add UnOpSpec @one_term
+
+ .. deprecated:: 8.13
+ Use :cmd:`Add Zify` ``UnOpSpec`` instead.
+
+.. cmd:: Add CstOp @one_term
+
+ .. deprecated:: 8.13
+ Use :cmd:`Add Zify` ``CstOp`` instead.
-.. cmd:: Add InjTyp
+.. cmd:: Add BinRel @one_term
.. deprecated:: 8.13
- Use instead either :cmd:`Add Zify` ``InjTyp``.
+ Use :cmd:`Add Zify` ``BinRel`` instead.
-.. cmd:: Add BinOp
+.. cmd:: Add PropOp @one_term
.. deprecated:: 8.13
- Use instead either :cmd:`Add Zify` ``BinOp``.
+ Use :cmd:`Add Zify` ``PropOp`` instead.
-.. cmd:: Add UnOp
+.. cmd:: Add PropBinOp @one_term
.. deprecated:: 8.13
- Use instead either :cmd:`Add Zify` ``UnOp``.
+ Use :cmd:`Add Zify` ``PropBinOp`` instead.
-.. cmd:: Add CstOp
+.. cmd:: Add PropUOp @one_term
.. deprecated:: 8.13
- Use instead either :cmd:`Add Zify` ``CstOp``.
+ Use :cmd:`Add Zify` ``PropUOp`` instead.
-.. cmd:: Add BinRel
+.. cmd:: Add Saturate @one_term
.. deprecated:: 8.13
- Use instead either :cmd:`Add Zify` ``BinRel``.
+ Use :cmd:`Add Zify` ``Saturate`` instead.
diff --git a/doc/sphinx/addendum/miscellaneous-extensions.rst b/doc/sphinx/addendum/miscellaneous-extensions.rst
index 0e8660cb0e..3944a34cdc 100644
--- a/doc/sphinx/addendum/miscellaneous-extensions.rst
+++ b/doc/sphinx/addendum/miscellaneous-extensions.rst
@@ -7,10 +7,10 @@ of program refinements. To use the Derive extension it must first be
required with ``Require Coq.derive.Derive``. When the extension is loaded,
it provides the following command:
-.. cmd:: Derive @ident__1 SuchThat @type As @ident__2
+.. cmd:: Derive @ident__1 SuchThat @one_term As @ident__2
- :n:`@ident__1` can appear in :n:`@type`. This command opens a new proof
- presenting the user with a goal for :n:`@type` in which the name :n:`@ident__1` is
+ :n:`@ident__1` can appear in :n:`@one_term`. This command opens a new proof
+ presenting the user with a goal for :n:`@one_term` in which the name :n:`@ident__1` is
bound to an existential variable :g:`?x` (formally, there are other goals
standing for the existential variables but they are shelved, as
described in :tacn:`shelve`).
diff --git a/doc/sphinx/addendum/nsatz.rst b/doc/sphinx/addendum/nsatz.rst
index 8a64a7ed4b..7a2be3dcef 100644
--- a/doc/sphinx/addendum/nsatz.rst
+++ b/doc/sphinx/addendum/nsatz.rst
@@ -1,12 +1,20 @@
.. _nsatz_chapter:
-Nsatz: tactics for proving equalities in integral domains
+Nsatz: a solver for equalities in integral domains
===========================================================
:Author: Loïc Pottier
-.. tacn:: nsatz
- :name: nsatz
+
+To use the tactics described in this section, load the ``Nsatz`` module with the
+command ``Require Import Nsatz``. Alternatively, if you prefer not to transitively depend on the
+files that declare the axioms used to define the real numbers, you can
+``Require Import NsatzTactic`` instead; this will still allow
+:tacn:`nsatz` to solve goals defined about :math:`\mathbb{Z}`,
+:math:`\mathbb{Q}` and any user-registered rings.
+
+
+.. tacn:: nsatz {? with radicalmax := @one_term strategy := @one_term parameters := @one_term variables := @one_term }
This tactic is for solving goals of the form
@@ -32,13 +40,36 @@ Nsatz: tactics for proving equalities in integral domains
doing automatic introductions.
- You can load the ``Nsatz`` module with the command ``Require Import Nsatz``.
+ `radicalmax`
+ bound when searching for r such that
+ :math:`c (P−Q) r = \sum_{i=1..s} S_i (P i − Q i)`.
+ This argument must be of type `N` (binary natural numbers).
- Alternatively, if you prefer not to transitively depend on the
- files declaring the axioms used to define the real numbers, you can
- ``Require Import NsatzTactic`` instead; this will still allow
- :tacn:`nsatz` to solve goals defined about :math:`\mathbb{Z}`,
- :math:`\mathbb{Q}` and any user-registered rings.
+ `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%Z`: reverse lexicographic order and newest s-polynomial.
+ * `strategy := 1%Z`: reverse lexicographic order and sugar strategy.
+ * `strategy := 2%Z`: pure lexicographic order and newest s-polynomial.
+ * `strategy := 3%Z`: pure lexicographic order and sugar strategy.
+
+ `parameters`
+ a list of parameters of type `R`, containing the variables :math:`X_{i_1},\ldots,X_{i_k}` among
+ :math:`X_1,\ldots,X_n`. Computation will be performed with
+ rational fractions in these parameters, i.e. polynomials have
+ coefficients in :math:`R(X_{i_1},\ldots,X_{i_k})`. In this case, the coefficient
+ :math:`c` can be a nonconstant 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`
+ a list of variables of type `R` in the decreasing order in
+ which they will be used in the Buchberger algorithm. If the list is empty,
+ then `lvar` is replaced by all the variables which are not in
+ `parameters`.
+
+ See the file `Nsatz.v <https://github.com/coq/coq/blob/master/test-suite/success/Nsatz.v>`_
+ for examples, especially in geometry.
More about `nsatz`
---------------------
@@ -63,32 +94,3 @@ Buchberger algorithm.
This computation is done after a step of *reification*, which is
performed using :ref:`typeclasses`.
-
-.. tacv:: nsatz with radicalmax:=@natural%N strategy:=@natural%Z parameters:=[{*, @ident}] variables:=[{*, @ident}]
-
- Most complete syntax for `nsatz`.
-
- * `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 = 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.
-
- * `variables` is the list of the variables in the decreasing order in
- which they will be used in the Buchberger algorithm. If `variables` = :g:`(@nil R)`,
- then `lvar` is replaced by all the variables which are not in
- `parameters`.
-
-See the test-suite file `Nsatz.v <https://github.com/coq/coq/blob/master/test-suite/success/Nsatz.v>`_ for many examples, especially in geometry.
diff --git a/doc/sphinx/addendum/omega.rst b/doc/sphinx/addendum/omega.rst
index e1b1ee8e8d..5c08bc44df 100644
--- a/doc/sphinx/addendum/omega.rst
+++ b/doc/sphinx/addendum/omega.rst
@@ -1,6 +1,6 @@
.. _omega_chapter:
-Omega: a solver for quantifier-free problems in Presburger Arithmetic
+Omega: a (deprecated) solver for arithmetic
=====================================================================
:Author: Pierre Crégut
@@ -9,7 +9,7 @@ Omega: a solver for quantifier-free problems in Presburger Arithmetic
The :tacn:`omega` tactic is deprecated in favor of the :tacn:`lia`
tactic. The goal is to consolidate the arithmetic solving
- capabilities of Coq into a single engine; moreover, :tacn:`lia` is
+ capabilities of |Coq| into a single engine; moreover, :tacn:`lia` is
in general more powerful than :tacn:`omega` (it is a complete
Presburger arithmetic solver while :tacn:`omega` was known to be
incomplete).
@@ -143,7 +143,7 @@ Options
.. deprecated:: 8.5
- This deprecated flag (on by default) is for compatibility with Coq pre 8.5. It
+ This deprecated flag (on by default) is for compatibility with |Coq| pre 8.5. It
resets internal name counters to make executions of :tacn:`omega` independent.
.. flag:: Omega UseLocalDefs
diff --git a/doc/sphinx/addendum/program.rst b/doc/sphinx/addendum/program.rst
index c6a4b4fe1a..5da1ac3f46 100644
--- a/doc/sphinx/addendum/program.rst
+++ b/doc/sphinx/addendum/program.rst
@@ -22,7 +22,7 @@ complete |Coq| term. |Program| replaces the |Program| tactic by Catherine
Parent :cite:`Parent95b` which had a similar goal but is no longer maintained.
The languages available as input are currently restricted to |Coq|’s
-term language, but may be extended to OCaml, Haskell and
+term language, but may be extended to |OCaml|, Haskell and
others in the future. We use the same syntax as |Coq| and permit to use
implicit arguments and the existing coercion mechanism. Input terms
and types are typed in an extended system (Russell) and interpreted
@@ -33,7 +33,7 @@ obligations which need to be resolved to create the final term.
.. _elaborating-programs:
Elaborating programs
----------------------
+--------------------
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
@@ -83,7 +83,7 @@ coercions.
.. flag:: Program Cases
- This controls the special treatment of pattern matching generating equalities
+ Controls the special treatment of pattern matching generating equalities
and disequalities when using |Program| (it is on by default). All
pattern-matches and let-patterns are handled using the standard algorithm
of |Coq| (see :ref:`extendedpatternmatching`) when this flag is
@@ -91,7 +91,7 @@ coercions.
.. flag:: Program Generalized Coercion
- This controls the coercion of general inductive types when using |Program|
+ Controls the coercion of general inductive types when using |Program|
(the flag is on by default). Coercion of subset types and pairs is still
active in this case.
@@ -104,16 +104,16 @@ coercions.
typechecking.
.. attr:: program
+ :name: program; Program
- This attribute allows to use the Program mode on a specific
+ Allows using the Program mode on a specific
definition. An alternative syntax is to use the legacy ``Program``
- prefix (cf. :n:`@legacy_attr`) as documented in the rest of this
- chapter.
+ prefix (cf. :n:`@legacy_attr`) as it is elsewhere in this chapter.
.. _syntactic_control:
Syntactic control over equalities
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To give more control over the generation of equalities, the
type checker will fall back directly to |Coq|’s usual typing of dependent
@@ -158,36 +158,20 @@ prove some goals to construct the final definitions.
Program Definition
~~~~~~~~~~~~~~~~~~
-.. cmd:: Program Definition @ident := @term
-
- This command types the value term in Russell and generates proof
- obligations. Once solved using the commands shown below, it binds the
- final |Coq| term to the name :n:`@ident` in the environment.
-
- .. exn:: @ident already exists.
- :name: @ident already exists. (Program Definition)
- :undocumented:
-
- .. cmdv:: Program Definition @ident : @type := @term
-
- It interprets the type :n:`@type`, potentially generating proof
- obligations to be resolved. Once done with them, we have a |Coq|
- type :n:`@type__0`. It then elaborates the preterm :n:`@term` into a |Coq|
- term :n:`@term__0`, checking that the type of :n:`@term__0` is coercible to
- :n:`@type__0`, and registers :n:`@ident` as being of type :n:`@type__0` once the
- set of obligations generated during the interpretation of :n:`@term__0`
- and the aforementioned coercion derivation are solved.
-
- .. exn:: In environment … the term: @term does not have type @type. Actually, it has type ...
- :undocumented:
+A :cmd:`Definition` command with the :attr:`program` attribute types
+the value term in Russell and generates proof
+obligations. Once solved using the commands shown below, it binds the
+final |Coq| term to the name :n:`@ident` in the environment.
- .. cmdv:: Program Definition @ident {* @binder } : @type := @term
+:n:`Program Definition @ident : @type := @term`
- This is equivalent to:
-
- :n:`Program Definition @ident : forall {* @binder }, @type := fun {* @binder } => @term`.
-
- .. TODO refer to production in alias
+Interprets the type :n:`@type`, potentially generating proof
+obligations to be resolved. Once done with them, we have a |Coq|
+type :n:`@type__0`. It then elaborates the preterm :n:`@term` into a |Coq|
+term :n:`@term__0`, checking that the type of :n:`@term__0` is coercible to
+:n:`@type__0`, and registers :n:`@ident` as being of type :n:`@type__0` once the
+set of obligations generated during the interpretation of :n:`@term__0`
+and the aforementioned coercion derivation are solved.
.. seealso:: Sections :ref:`vernac-controlling-the-reduction-strategies`, :tacn:`unfold`
@@ -196,20 +180,8 @@ Program Definition
Program Fixpoint
~~~~~~~~~~~~~~~~
-.. cmd:: Program Fixpoint @fix_definition {* with @fix_definition }
-
- The optional :n:`@fixannot` annotation can be one of:
-
- + :g:`measure f R` where :g:`f` is a value of type :g:`X` computed on
- any subset of the arguments and the optional term
- :g:`R` is a relation on :g:`X`. :g:`X` defaults to :g:`nat` and :g:`R`
- to :g:`lt`.
-
- + :g:`wf R x` which is equivalent to :g:`measure x R`.
-
- 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.
+A :cmd:`Fixpoint` command with the :attr:`program` attribute may also generate obligations. It works
+with mutually recursive definitions too. For example:
.. coqtop:: reset in
@@ -223,6 +195,17 @@ Program Fixpoint
| _ => O
end.
+The :cmd:`Fixpoint` command may include an optional :n:`@fixannot` annotation, which can be:
+
++ :g:`measure f R` where :g:`f` is a value of type :g:`X` computed on
+ any subset of the arguments and the optional term
+ :g:`R` is a relation on :g:`X`. :g:`X` defaults to :g:`nat` and :g:`R`
+ to :g:`lt`.
+
++ :g:`wf R x` which is equivalent to :g:`measure x R`.
+
+.. todo see https://github.com/coq/coq/pull/12936#discussion_r492747830
+
Here we have one obligation for each branch (branches for :g:`0` and
``(S 0)`` are automatically generated by the pattern matching
compilation algorithm).
@@ -246,8 +229,6 @@ using the syntax:
| _ => O
end.
-
-
.. caution:: When defining structurally recursive functions, the generated
obligations should have the prototype of the currently defined
functional in their context. In this case, the obligations should be
@@ -266,67 +247,70 @@ using the syntax:
Program Lemma
~~~~~~~~~~~~~
-.. cmd:: Program Lemma @ident : @type
-
- The Russell language can also be used to type statements of logical
- properties. It will generate obligations, try to solve them
- automatically and fail if some unsolved obligations remain. In this
- case, one can first define the lemma’s statement using :g:`Program
- 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.
+A :cmd:`Lemma` command with the :attr:`program` attribute uses the Russell
+language to type statements of logical
+properties. It generates obligations, tries to solve them
+automatically and fails if some unsolved obligations remain. In this
+case, one can first define the lemma’s statement using :cmd:`Definition`
+and use it as the goal afterwards. Otherwise the proof
+will be started with the elaborated version as a goal. The
+:attr:`Program` attribute can similarly be used with
+:cmd:`Variable`, :cmd:`Hypothesis`, :cmd:`Axiom` etc.
.. _solving_obligations:
Solving obligations
---------------------
+-------------------
The following commands are available to manipulate obligations. The
optional identifier is used when multiple functions have unsolved
obligations (e.g. when defining mutually recursive blocks). The
optional tactic is replaced by the default one if not specified.
-.. cmd:: {? {| Local | Global } } Obligation Tactic := @ltac_expr
+.. cmd:: Obligation Tactic := @ltac_expr
:name: Obligation Tactic
Sets the default obligation solving tactic applied to all obligations
automatically, whether to solve them or when starting to prove one,
- e.g. using :g:`Next`. :g:`Local` makes the setting last only for the current
- module. Inside sections, local is the default.
+ e.g. using :cmd:`Next Obligation`.
+
+ This command supports the :attr:`local` and :attr:`global` attributes.
+ :attr:`local` makes the setting last only for the current
+ module. :attr:`local` is the default inside sections while :attr:`global`
+ otherwise.
.. cmd:: Show Obligation Tactic
Displays the current default tactic.
-.. cmd:: Obligations {? of @ident}
+.. cmd:: Obligations {? of @ident }
Displays all remaining obligations.
-.. cmd:: Obligation @natural {? of @ident}
+.. cmd:: Obligation @natural {? of @ident } {? : @type {? with @ltac_expr } }
Start the proof of obligation :token:`natural`.
-.. cmd:: Next Obligation {? of @ident}
+.. cmd:: Next Obligation {? of @ident } {? with @ltac_expr }
Start the proof of the next unsolved obligation.
-.. cmd:: Solve Obligations {? {? of @ident} with @ltac_expr}
+.. cmd:: Solve Obligations {? of @ident } {? with @ltac_expr }
- Tries to solve each obligation of ``ident`` using the given ``tactic`` or the default one.
+ Tries to solve each obligation of :token:`ident` using the given :token:`ltac_expr` or the default one.
-.. cmd:: Solve All Obligations {? with @ltac_expr}
+.. cmd:: Solve All Obligations {? with @ltac_expr }
Tries to solve each obligation of every program using the given
tactic or the default one (useful for mutually recursive definitions).
-.. cmd:: Admit Obligations {? of @ident}
+.. cmd:: Admit Obligations {? of @ident }
- Admits all obligations (of ``ident``).
+ Admits all obligations (of :token:`ident`).
.. note:: Does not work with structurally recursive programs.
-.. cmd:: Preterm {? of @ident}
+.. cmd:: Preterm {? of @ident }
Shows the term that will be fed to the kernel once the obligations
are solved. Useful for debugging.
diff --git a/doc/sphinx/addendum/ring.rst b/doc/sphinx/addendum/ring.rst
index cda8a1b679..027db9f47a 100644
--- a/doc/sphinx/addendum/ring.rst
+++ b/doc/sphinx/addendum/ring.rst
@@ -10,8 +10,8 @@
.. _theringandfieldtacticfamilies:
-The ring and field tactic families
-====================================
+ring and field: solvers for polynomial and rational equations
+=============================================================
:Author: Bruno Barras, Benjamin Grégoire, Assia Mahboubi, Laurent Théry [#f1]_
@@ -99,10 +99,10 @@ Yes, building the variables map and doing the substitution after
normalizing is automatically done by the tactic. So you can just
forget this paragraph and use the tactic according to your intuition.
-Concrete usage in Coq
+Concrete usage in |Coq|
--------------------------
-.. tacn:: ring {? [ {+ @term } ] }
+.. tacn:: ring {? [ {+ @one_term } ] }
Solves polynomical equations of a ring
(or semiring) structure. It proceeds by normalizing both sides
@@ -110,14 +110,35 @@ Concrete usage in Coq
distributivity, constant propagation, rewriting of monomials) and
syntactically comparing the results.
-.. tacn:: ring_simplify {? [ {+ @term } ] } {+ @term } {? in @ident }
+ :n:`[ {+ @one_term } ]`
+ If specified, the tactic decides the equality of two terms modulo ring operations and
+ the equalities defined by the :token:`one_term`\s.
+ Each :token:`one_term` has to be a proof of some equality :g:`m = p`, where :g:`m`
+ is a monomial (after “abstraction”), :g:`p` a polynomial and :g:`=` is the
+ corresponding equality of the ring structure.
+
+.. tacn:: ring_simplify {? [ {+ @one_term } ] } {+ @one_term } {? in @ident }
Applies the normalization procedure described above to
- 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
+ the given :token:`one_term`\s. The tactic then replaces all occurrences of the :token:`one_term`\s
+ given in the conclusion of the goal by their normal forms. If no :token:`one_term`
is given, then the conclusion should be an equation and both
sides are normalized. The tactic can also be applied in a hypothesis.
+ :n:`in @ident`
+ If specified, the tactic performs the simplification in the hypothesis named :token:`ident`.
+
+ .. note::
+
+ :n:`ring_simplify @one_term__1; ring_simplify @one_term__2` is not equivalent to
+ :n:`ring_simplify @one_term__1 @one_term__2`.
+
+ In the latter case the variables map is shared between the two :token:`one_term`\s, and
+ common subterm :g:`t` of :n:`@one_term__1` and :n:`@one_term__2`
+ will have the same associated variable number. So the first
+ alternative should be avoided for :token:`one_term`\s belonging to the same ring
+ theory.
+
The tactic must be loaded by ``Require Import Ring``. The ring structures
must be declared with the ``Add Ring`` command (see below). The ring of
booleans is predefined; if one wants to use the tactic on |nat| one must
@@ -147,31 +168,6 @@ Concrete usage in Coq
Abort.
-.. tacv:: ring [{* @term }]
-
- This tactic decides the equality of two terms modulo ring operations and
- the equalities defined by the :token:`term`\ s.
- Each :token:`term` has to be a proof of some equality :g:`m = p`, where :g:`m`
- is a monomial (after “abstraction”), :g:`p` a polynomial and :g:`=` the
- corresponding equality of the ring structure.
-
-.. tacv:: ring_simplify [{* @term }] {* @term } in @ident
-
- This tactic performs the simplification in the hypothesis named :token:`ident`.
-
-
-.. note::
-
- :n:`ring_simplify @term__1; ring_simplify @term__2` is not equivalent to
- :n:`ring_simplify @term__1 @term__2`.
-
- In the latter case the variables map is shared between the two terms, and
- common subterm :g:`t` of :n:`@term__1` and :n:`@term__2`
- will have the same associated variable number. So the first
- alternative should be avoided for terms belonging to the same ring
- theory.
-
-
Error messages:
@@ -433,10 +429,10 @@ How does it work?
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
+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
+|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
@@ -515,15 +511,27 @@ application of the main correctness theorem to well-chosen arguments.
Dealing with fields
------------------------
-.. tacn:: field {? [ {+ @term } ] }
+.. tacn:: field {? [ {+ @one_term } ] }
- This tactic is an extension of the :tacn:`ring` tactic that deals with rational
+ An extension of the :tacn:`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
:math:`N = 0`.
+ :n:`[ {+ @one_term } ]`
+ If specified, the tactic decides the equality of two terms modulo
+ field operations and the equalities defined
+ by the :token:`one_term`\s. Each :token:`one_term` has to be a proof of some equality
+ :g:`m = p`, where :g:`m` is a monomial (after “abstraction”), :g:`p` a polynomial
+ and :g:`=` the corresponding equality of the field structure.
+
+ .. note::
+
+ Rewriting works with the equality :g:`m = p` only if :g:`p` is a polynomial since
+ rewriting is handled by the underlying ring tactic.
+
Note that :n:`field` also generates nonzero conditions for all the
denominators it encounters in the reduction. In our example, it
generates the condition :math:`x \neq 0`. These conditions appear as one subgoal
@@ -559,71 +567,36 @@ Dealing with fields
intros x y H H1; field [H1]; auto.
Abort.
-.. tacv:: field [{* @term}]
-
- This tactic decides the equality of two terms modulo
- field operations and the equalities defined
- by the :token:`term`\s. Each :token:`term` has to be a proof of some equality
- :g:`m = p`, where :g:`m` is a monomial (after “abstraction”), :g:`p` a polynomial
- and :g:`=` the corresponding equality of the field structure.
-
-.. note::
-
- Rewriting works with the equality :g:`m = p` only if :g:`p` is a polynomial since
- rewriting is handled by the underlying ring tactic.
-
-.. tacn:: field_simplify {? [ {+ @term } ] } {+ @term } {? in @ident }
+.. tacn:: field_simplify {? [ {+ @one_term__eq } ] } {+ @one_term } {? in @ident }
- performs the simplification in the conclusion of the
+ 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
fraction simplification. This yields smaller expressions when
reducing to the same denominator since common factors can be canceled.
-.. tacv:: field_simplify [{* @term }]
-
- This variant performs the simplification in the conclusion of the goal using the equalities
- defined by the :token:`term`\s.
-
-.. tacv:: field_simplify [{* @term }] {* @term }
-
- This variant performs the simplification in the terms :token:`term`\s of the conclusion of the goal
- using the equalities defined by :token:`term`\s inside the brackets.
-
-.. tacv:: field_simplify in @ident
-
- This variant performs the simplification in the assumption :token:`ident`.
-
-.. tacv:: field_simplify [{* @term }] in @ident
-
- This variant performs the simplification
- in the assumption :token:`ident` using the equalities defined by the :token:`term`\s.
-
-.. tacv:: field_simplify [{* @term }] {* @term } in @ident
-
- This variant performs the simplification in the :token:`term`\s of the
- assumption :token:`ident` using the
- equalities defined by the :token:`term`\s inside the brackets.
-
-.. tacn:: field_simplify_eq {? [ {+ @term } ] } {? in @ident }
-
- performs the simplification in the conclusion of
- the goal removing the denominator. :math:`F_1 = F_2` becomes :math:`N_1 D_2 = N_2 D_1`.
+ :n:`[ {+ @one_term__eq } ]`
+ Do simplification in the conclusion of the goal using the equalities
+ defined by these :token:`one_term`\s.
-.. tacv:: field_simplify_eq [ {* @term }]
+ :n:`{+ @one_term }`
+ Terms to simplify in the conclusion.
- This variant performs the simplification in
- the conclusion of the goal using the equalities defined by :token:`term`\s.
+ :n:`in @ident`
+ If specified, substitute in the hypothesis :n:`@ident` instead of the conclusion.
-.. tacv:: field_simplify_eq in @ident
+.. tacn:: field_simplify_eq {? [ {+ @one_term } ] } {? in @ident }
- This variant performs the simplification in the assumption :token:`ident`.
+ Performs the simplification in the conclusion of
+ the goal, removing the denominator. :math:`F_1 = F_2` becomes :math:`N_1 D_2 = N_2 D_1`.
-.. tacv:: field_simplify_eq [{* @term}] in @ident
+ :n:`[ {+ @one_term } ]`
+ Do simplification in the conclusion of the goal using the equalities
+ defined by these :token:`one_term`\s.
- This variant performs the simplification in the assumption :token:`ident`
- using the equalities defined by :token:`term`\s and removing the denominator.
+ :n:`in @ident`
+ If specified, simplify in the hypothesis :n:`@ident` instead of the conclusion.
Adding a new field structure
diff --git a/doc/sphinx/addendum/type-classes.rst b/doc/sphinx/addendum/type-classes.rst
index d533470f22..7638fce010 100644
--- a/doc/sphinx/addendum/type-classes.rst
+++ b/doc/sphinx/addendum/type-classes.rst
@@ -13,7 +13,7 @@ Class and Instance declarations
-------------------------------
The syntax for class and instance declarations is the same as the record
-syntax of Coq:
+syntax of |Coq|:
.. coqdoc::
@@ -61,7 +61,7 @@ Note that if you finish the proof with :cmd:`Qed` the entire instance
will be opaque, including the fields given in the initial term.
Alternatively, in :flag:`Program Mode` if one does not give all the
-members in the Instance declaration, Coq generates obligations for the
+members in the Instance declaration, |Coq| generates obligations for the
remaining fields, e.g.:
.. coqtop:: in
@@ -242,7 +242,7 @@ binders. For example:
Definition lt `{eqa : EqDec A, ! Ord eqa} (x y : A) := andb (le x y) (neqb x y).
The ``!`` modifier switches the way a binder is parsed back to the usual
-interpretation of Coq. In particular, it uses the implicit arguments
+interpretation of |Coq|. In particular, it uses the implicit arguments
mechanism if available, as shown in the example.
Substructures
@@ -295,10 +295,29 @@ the Existing Instance command to achieve the same effect.
Summary of the commands
-----------------------
-.. cmd:: Class @inductive_definition {* with @inductive_definition }
+.. cmd:: Class @record_definition
+ Class @singleton_class_definition
- The :cmd:`Class` command is used to declare a typeclass with parameters
- :n:`{* @binder }` and fields the declared record fields.
+ .. insertprodn singleton_class_definition singleton_class_definition
+
+ .. prodn::
+ singleton_class_definition ::= {? > } @ident_decl {* @binder } {? : @sort } := @constructor
+
+ The first form declares a record and makes the record a typeclass with parameters
+ :n:`{* @binder }` and the listed record fields.
+
+ .. _singleton-class:
+
+ The second form declares a *singleton* class with a single method. This
+ singleton class is a so-called definitional class, represented simply
+ as a definition ``ident binders := term`` and whose instances are
+ themselves objects of this type. Definitional classes are not wrapped
+ inside records, and the trivial projection of an instance of such a
+ class is convertible to the instance itself. This can be useful to
+ make instances of existing objects easily and to reduce proof size by
+ not inserting useless projections. The class constant itself is
+ declared rigid during resolution so that the class abstraction is
+ maintained.
Like any command declaring a record, this command supports the
:attr:`universes(polymorphic)`, :attr:`universes(monomorphic)`,
@@ -306,22 +325,7 @@ Summary of the commands
:attr:`universes(cumulative)`, :attr:`universes(noncumulative)` and
:attr:`private(matching)` attributes.
- .. _singleton-class:
-
- .. cmdv:: Class @ident {* @binder } : {? @sort} := @ident : @term
-
- This variant declares a *singleton* class with a single method. This
- singleton class is a so-called definitional class, represented simply
- as a definition ``ident binders := term`` and whose instances are
- themselves objects of this type. Definitional classes are not wrapped
- inside records, and the trivial projection of an instance of such a
- class is convertible to the instance itself. This can be useful to
- make instances of existing objects easily and to reduce proof size by
- not inserting useless projections. The class constant itself is
- declared rigid during resolution so that the class abstraction is
- maintained.
-
- .. cmdv:: Existing Class @ident
+ .. cmd:: Existing Class @qualid
This variant declares a class from a previously declared constant or
inductive definition. No methods or instances are defined.
@@ -330,27 +334,31 @@ Summary of the commands
This command has no effect when used on a typeclass.
-.. cmd:: Instance @ident {* @binder } : @term__0 {+ @term} {? | @natural} := { {*; @field_def} }
+.. cmd:: Instance {? @ident_decl {* @binder } } : @type {? @hint_info } {? {| := %{ {* @field_def } %} | := @term } }
+
+ .. insertprodn hint_info hint_info
- This command is used to declare a typeclass instance named
- :token:`ident` of the class :n:`@term__0` with parameters :token:`term` and
+ .. prodn::
+ hint_info ::= %| {? @natural } {? @one_term }
+
+ Declares a typeclass instance named
+ :token:`ident_decl` of the class :n:`@type` with the specified parameters and with
fields defined by :token:`field_def`, where each field must be a declared field of
the class.
- An arbitrary context of :n:`{* @binder }` can be put after the name of the
- instance and before the colon to declare a parameterized instance. An
- optional priority can be declared, 0 being the highest priority as for
- :tacn:`auto` hints. If the priority :token:`natural` is not specified, it defaults to the number
+ Add one or more :token:`binder`\s to declare a parameterized instance. :token:`hint_info`
+ specifies the hint priority, where 0 is the highest priority as for
+ :tacn:`auto` hints. If the priority is not specified, the default is the number
of non-dependent binders of the instance.
This command supports the :attr:`global` attribute that can be
used on instances declared in a section so that their
- generalization is automatically redeclared after the section is
+ generalization is automatically redeclared when the section is
closed.
Like :cmd:`Definition`, it also supports the :attr:`program`
attribute to switch the type checking to `Program` (chapter
- :ref:`programs`) and use the obligation mechanism to manage missing
+ :ref:`programs`) and to use the obligation mechanism to manage missing
fields.
Finally, it supports the lighter :attr:`refine` attribute:
@@ -362,67 +370,43 @@ Summary of the commands
to fill them. It works exactly as if no body had been given and
the :tacn:`refine` tactic has been used first.
- .. cmdv:: Instance @ident {* @binder } : forall {* @binder }, @term__0 {+ @term} {? | @natural } := @term
-
- This syntax is used for declaration of singleton class instances or
- for directly giving an explicit term of type :n:`forall {* @binder }, @term__0
- {+ @term}`. One need not even mention the unique field name for
- singleton classes.
-
- .. cmdv:: Declare Instance
- :name: Declare Instance
+ .. cmd:: Declare Instance @ident_decl {* @binder } : @term {? @hint_info }
- In a :cmd:`Module Type`, this command states that a corresponding concrete
+ In a :cmd:`Module Type`, declares that a corresponding concrete
instance should exist in any implementation of this :cmd:`Module Type`. This
is similar to the distinction between :cmd:`Parameter` vs. :cmd:`Definition`, or
between :cmd:`Declare Module` and :cmd:`Module`.
-Besides the :cmd:`Class` and :cmd:`Instance` vernacular commands, there are a
-few other commands related to typeclasses.
+ .. cmd:: Existing Instance @qualid {? @hint_info }
+ Existing Instances {+ @qualid } {? %| @natural }
+
+ Adds a constant whose type ends with
+ an applied typeclass to the instance database with an optional
+ priority :token:`natural`. It can be used for redeclaring instances at the end of
+ sections, or declaring structure projections as instances. This is
+ equivalent to ``Hint Resolve ident : typeclass_instances``, except it
+ registers instances for :cmd:`Print Instances`.
+
+.. cmd:: Print Instances @reference
-.. cmd:: Existing Instance {+ @ident} {? | @natural}
+ Shows the list of instances associated with the typeclass :token:`reference`.
- This command adds an arbitrary list of constants whose type ends with
- an applied typeclass to the instance database with an optional
- priority :token:`natural`. It can be used for redeclaring instances at the end of
- sections, or declaring structure projections as instances. This is
- equivalent to ``Hint Resolve ident : typeclass_instances``, except it
- registers instances for :cmd:`Print Instances`.
-.. tacn:: typeclasses eauto
- :name: typeclasses eauto
+.. tacn:: typeclasses eauto {? bfs } {? @int_or_var } {? with {+ @ident } }
- This proof search tactic implements the resolution engine that is run
+ This proof search tactic uses the resolution engine that is run
implicitly during type checking. This tactic uses a different resolution
engine than :tacn:`eauto` and :tacn:`auto`. The main differences are the
following:
- + Contrary to :tacn:`eauto` and :tacn:`auto`, the resolution is done entirely in
- the new proof engine (as of Coq 8.6), meaning that backtracking is
+ + Unlike :tacn:`eauto` and :tacn:`auto`, the resolution is done entirely in
+ the proof engine, meaning that backtracking is
available among dependent subgoals, and shelving goals is supported.
``typeclasses eauto`` is a multi-goal tactic. It analyses the dependencies
between subgoals to avoid backtracking on subgoals that are entirely
independent.
- + When called with no arguments, ``typeclasses eauto`` uses
- the ``typeclass_instances`` database by default (instead of core).
- Dependent subgoals are automatically shelved, and shelved goals can
- remain after resolution ends (following the behavior of Coq 8.5).
-
- .. note::
- As of Coq 8.6, ``all:once (typeclasses eauto)`` faithfully
- mimics what happens during typeclass resolution when it is called
- during refinement/type inference, except that *only* declared class
- subgoals are considered at the start of resolution during type
- inference, while ``all`` can select non-class subgoals as well. It might
- move to ``all:typeclasses eauto`` in future versions when the
- refinement engine will be able to backtrack.
-
- + When called with specific databases (e.g. with), ``typeclasses eauto``
- allows shelved goals to remain at any point during search and treat
- 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 local hypotheses, we use the transparent
@@ -446,26 +430,44 @@ few other commands related to typeclasses.
+ When considering local hypotheses, we use the union of all the modes
declared in the given databases.
- .. tacv:: typeclasses eauto @natural
+ + Use the :cmd:`Typeclasses eauto` command to customize the behavior of
+ this tactic.
- .. warning::
- The semantics for the limit :n:`@natural`
- is different than for auto. By default, if no limit is given, the
- search is unbounded. Contrary to :tacn:`auto`, introduction steps are
- counted, which might result in larger limits being necessary when
- searching with ``typeclasses eauto`` than with :tacn:`auto`.
+ :n:`@int_or_var`
+ Specifies the maximum depth of the search.
- .. tacv:: typeclasses eauto with {+ @ident}
+ .. warning::
+ The semantics for the limit :n:`@int_or_var`
+ are different than for :tacn:`auto`. By default, if no limit is given, the
+ search is unbounded. Unlike :tacn:`auto`, introduction steps count against
+ the limit, which might result in larger limits being necessary when
+ searching with :tacn:`typeclasses eauto` than with :tacn:`auto`.
+
+ :n:`with {+ @ident }`
+ Runs resolution with the specified hint databases. It treats
+ typeclass subgoals the same as other subgoals (no shelving of
+ non-typeclass goals in particular), while allowing shelved goals
+ to remain at any point during search.
+
+ When :n:`with` is not specified, :tacn:`typeclasses eauto` uses
+ the ``typeclass_instances`` database by default (instead of ``core``).
+ Dependent subgoals are automatically shelved, and shelved goals can
+ remain after resolution ends (following the behavior of Coq 8.5).
- This variant runs resolution with the given hint databases. It treats
- typeclass subgoals the same as other subgoals (no shelving of
- non-typeclass goals in particular).
+ .. note::
+ ``all:once (typeclasses eauto)`` faithfully
+ mimics what happens during typeclass resolution when it is called
+ during refinement/type inference, except that *only* declared class
+ subgoals are considered at the start of resolution during type
+ inference, while ``all`` can select non-class subgoals as well. It might
+ move to ``all:typeclasses eauto`` in future versions when the
+ refinement engine will be able to backtrack.
-.. tacn:: autoapply @term with @ident
+.. tacn:: autoapply @one_term with @ident
:name: autoapply
- The tactic ``autoapply`` applies a term using the transparency information
- of the hint database ident, and does *no* typeclass resolution. This can
+ The tactic ``autoapply`` applies :token:`one_term` using the transparency information
+ of the hint database :token:`ident`, and does *no* typeclass resolution. This can
be used in :cmd:`Hint Extern`’s for typeclass instances (in the hint
database ``typeclass_instances``) to allow backtracking on the typeclass
subgoals created by the lemma application, rather than doing typeclass
@@ -476,16 +478,16 @@ few other commands related to typeclasses.
Typeclasses Transparent, Typeclasses Opaque
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. cmd:: Typeclasses Transparent {+ @ident}
+.. cmd:: Typeclasses Transparent {+ @qualid }
- This command makes the identifiers transparent during typeclass
+ Makes :token:`qualid` transparent during typeclass
resolution.
- Shortcut for :n:`Hint Transparent {+ @ident } : typeclass_instances`.
+ A shortcut for :cmd:`Hint Transparent` :n:`{+ @qualid } : typeclass_instances`
-.. cmd:: Typeclasses Opaque {+ @ident}
+.. cmd:: Typeclasses Opaque {+ @qualid }
- Make the identifiers opaque for typeclass search.
- Shortcut for :n:`Hint Opaque {+ @ident } : typeclass_instances`.
+ Make :token:`qualid` opaque for typeclass search.
+ A shortcut for :cmd:`Hint Opaque` :n:`{+ @qualid } : typeclass_instances`.
It is useful when some constants prevent some unifications and make
resolution fail. It is also useful to declare constants which
@@ -511,13 +513,13 @@ Settings
This flag (off by default) respects the dependency order
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
+ the dependent ones previously (|Coq| 8.5 and below). This can result in
quite different performance behaviors of proof search.
.. flag:: Typeclasses Filtered Unification
- This flag, available since Coq 8.6 and off by default, switches the
+ This flag, which is off by default, switches the
hint application procedure to a filter-then-unify strategy. To apply a
hint, we first check that the goal *matches* syntactically the
inferred or specified pattern of the hint, and only then try to
@@ -601,22 +603,25 @@ Settings
of goals. Setting this option to 1 or 2 turns on the :flag:`Typeclasses Debug` flag; setting this
option to 0 turns that flag off.
-Typeclasses eauto `:=`
-~~~~~~~~~~~~~~~~~~~~~~
+Typeclasses eauto
+~~~~~~~~~~~~~~~~~
-.. cmd:: Typeclasses eauto := {? debug} {? {| (dfs) | (bfs) } } @natural
+.. cmd:: Typeclasses eauto := {? debug } {? ( {| bfs | dfs } ) } {? @natural }
:name: Typeclasses eauto
- This command allows more global customization of the typeclass
- resolution tactic. The semantics of the options are:
+ Allows more global customization of the :tacn:`typeclasses eauto` tactic.
+ The options are:
- + ``debug`` This sets the debug mode. In debug mode, the trace of
- successfully applied tactics is printed. The debug mode can also
+ ``debug``
+ Sets debug mode. In debug mode, a trace of
+ successfully applied tactics is printed. Debug mode can also
be set with :flag:`Typeclasses Debug`.
- + ``(dfs)``, ``(bfs)`` This sets the search strategy to depth-first
+ ``dfs``, ``bfs``
+ Sets the search strategy to depth-first
search (the default) or breadth-first search. The search strategy
can also be set with :flag:`Typeclasses Iterative Deepening`.
- + :token:`natural` This sets the depth limit of the search. The depth
- limit can also be set with :opt:`Typeclasses Depth`.
+ :token:`natural`
+ Sets the depth limit for the search. The limit can also be set with
+ :opt:`Typeclasses Depth`.
diff --git a/doc/sphinx/addendum/universe-polymorphism.rst b/doc/sphinx/addendum/universe-polymorphism.rst
index b0ef792bd1..dd26534ec7 100644
--- a/doc/sphinx/addendum/universe-polymorphism.rst
+++ b/doc/sphinx/addendum/universe-polymorphism.rst
@@ -123,6 +123,7 @@ Polymorphic, Monomorphic
-------------------------
.. attr:: universes(polymorphic)
+ :name: universes(polymorphic); Polymorphic
This attribute can be used to declare universe polymorphic
definitions and inductive types. There is also a legacy syntax
@@ -136,6 +137,7 @@ Polymorphic, Monomorphic
used.
.. attr:: universes(monomorphic)
+ :name: universes(monomorphic); Monomorphic
This attribute can be used to declare universe monomorphic
definitions and inductive types (i.e. global universe constraints
@@ -170,6 +172,7 @@ Cumulative, NonCumulative
-------------------------
.. attr:: universes(cumulative)
+ :name: universes(cumulative); Cumulative
Polymorphic inductive types, coinductive types, variants and
records can be declared cumulative using this attribute or the
@@ -200,6 +203,7 @@ Cumulative, NonCumulative
effect on *monomorphic* inductive definitions.
.. attr:: universes(noncumulative)
+ :name: universes(noncumulative); NonCumulative
Declares the inductive type as non-cumulative even if the
:flag:`Polymorphic Inductive Cumulativity` flag is on. There is
@@ -384,29 +388,26 @@ Explicit Universes
The syntax has been extended to allow users to explicitly bind names
to universes and explicitly instantiate polymorphic definitions.
-.. cmd:: Universe @ident
- Polymorphic Universe @ident
+.. cmd:: Universe {+ @ident }
- In the monorphic case, this command declares a new global universe
- named :token:`ident`, which can be referred to using its qualified name
- as well. Global universe names live in a separate namespace. The
- command supports the :attr:`universes(polymorphic)` attribute (or
- the ``Polymorphic`` prefix) only in sections, meaning the universe
- quantification will be discharged on each section definition
+ In the monomorphic case, declares new global universes
+ with the given names. Global universe names live in a separate namespace.
+ The command supports the :attr:`universes(polymorphic)` attribute (or
+ the ``Polymorphic`` legacy attribute) only in sections, meaning the universe
+ quantification will be discharged for each section definition
independently.
.. exn:: Polymorphic universes can only be declared inside sections, use Monomorphic Universe instead.
:undocumented:
-.. cmd:: Constraint @univ_constraint
- Polymorphic Constraint @univ_constraint
+.. cmd:: Constraint {+, @univ_constraint }
- This command declares a new constraint between named universes.
+ Declares new constraints between named universes.
- If consistent, the constraint is then enforced in the global
+ If consistent, the constraints are then enforced in the global
environment. Like :cmd:`Universe`, it can be used with the
:attr:`universes(polymorphic)` attribute (or the ``Polymorphic``
- prefix) in sections only to declare constraints discharged at
+ legacy attribute) in sections only to declare constraints discharged at
section closing time. One cannot declare a global constraint on
polymorphic universes.
diff --git a/doc/sphinx/appendix/history-and-changes/index.rst b/doc/sphinx/appendix/history-and-changes/index.rst
index 50ffec8e3f..b00a7cdb08 100644
--- a/doc/sphinx/appendix/history-and-changes/index.rst
+++ b/doc/sphinx/appendix/history-and-changes/index.rst
@@ -5,10 +5,10 @@ History and recent changes
==========================
This chapter is divided in two parts. The first one is about the
-:ref:`early history of Coq <history>` and is presented in
+:ref:`early history of |Coq| <history>` and is presented in
chronological order. The second one provides :ref:`release notes
-about recent versions of Coq <changes>` and is presented in reverse
-chronological order. When updating your copy of Coq to a new version
+about recent versions of |Coq| <changes>` and is presented in reverse
+chronological order. When updating your copy of |Coq| to a new version
(especially a new major version), it is strongly recommended that you
read the corresponding release notes. They may contain advice that
will help you understand the differences with the previous version and
diff --git a/doc/sphinx/changes.rst b/doc/sphinx/changes.rst
index af66efa95e..79f00a4a5a 100644
--- a/doc/sphinx/changes.rst
+++ b/doc/sphinx/changes.rst
@@ -34,10 +34,10 @@ The main changes include:
this takes precedence over the now deprecated :ref:`ssreflect search<812SSRSearch>`.
- Many additions and improvements of the :ref:`standard library<812Stdlib>`.
- Improvements to the :ref:`reference manual<812Refman>` include a more logical organization
- of chapters along with updated syntax descriptions that match Coq's grammar
+ of chapters along with updated syntax descriptions that match |Coq|'s grammar
in most but not all chapters.
-Additionally, the :tacn:`omega` tactic is deprecated in this version of Coq,
+Additionally, the :tacn:`omega` tactic is deprecated in this version of |Coq|,
and we recommend users to switch to :tacn:`lia` in new proof scripts (see
also the warning message in the :ref:`corresponding chapter
<omega_chapter>`).
@@ -46,7 +46,7 @@ See the `Changes in 8.12+beta1`_ section and following sections for the
detailed list of changes, including potentially breaking changes marked
with **Changed**.
-Coq's documentation is available at https://coq.github.io/doc/v8.12/refman (reference
+|Coq|'s documentation is available at https://coq.github.io/doc/v8.12/refman (reference
manual), and https://coq.github.io/doc/v8.12/stdlib (documentation of
the standard library). Developer documentation of the ML API is available
at https://coq.github.io/doc/v8.12/api.
@@ -55,8 +55,8 @@ Maxime Dénès, Emilio Jesús Gallego Arias, Gaëtan Gilbert, Michael
Soegtrop and Théo Zimmermann worked on maintaining and improving the
continuous integration system and package building infrastructure.
-Erik Martin-Dorel has maintained the `Coq Docker images
-<https://hub.docker.com/r/coqorg/coq>`_ that are used in many Coq
+Erik Martin-Dorel has maintained the `|Coq| Docker images
+<https://hub.docker.com/r/coqorg/coq>`_ that are used in many |Coq|
projects for continuous integration.
The OPAM repository for |Coq| packages has been maintained by
@@ -64,7 +64,7 @@ Guillaume Claret, Karl Palmskog, Matthieu Sozeau and Enrico Tassi with
contributions from many users. A list of packages is available at
https://coq.inria.fr/opam/www/.
-Previously, most components of Coq had a single principal maintainer.
+Previously, most components of |Coq| had a single principal maintainer.
This was changed in 8.12 (`#11295
<https://github.com/coq/coq/pull/11295>`_) so that every component now has
a team of maintainers, who are in charge of reviewing and
@@ -99,12 +99,12 @@ Nickolai Zeldovich and Théo Zimmermann.
Many power users helped to improve the design of this new version via
the GitHub issue and pull request system, the |Coq| development mailing list
coqdev@inria.fr, the coq-club@inria.fr mailing list, the `Discourse forum
-<https://coq.discourse.group/>`_ and the new `Coq Zulip chat <http://coq.zulipchat.com>`_
+<https://coq.discourse.group/>`_ and the new `|Coq| Zulip chat <http://coq.zulipchat.com>`_
(thanks to Cyril Cohen for organizing the move from Gitter).
Version 8.12's development spanned 6 months from the release of
|Coq| 8.11.0. Emilio Jesus Gallego Arias and Théo Zimmermann are
-the release managers of Coq 8.12. This release is the result of
+the release managers of |Coq| 8.12. This release is the result of
~500 PRs merged, closing ~100 issues.
| Nantes, June 2020,
@@ -131,7 +131,7 @@ Specification language, type inference
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- **Changed:**
- The deprecation warning raised since Coq 8.10 when a trailing
+ The deprecation warning raised since |Coq| 8.10 when a trailing
implicit is declared to be non-maximally inserted (with the command
:cmd:`Arguments`) has been turned into an error
(`#11368 <https://github.com/coq/coq/pull/11368>`_,
@@ -432,7 +432,7 @@ Tactics
fixes `#12210 <https://github.com/coq/coq/issues/12210>`_).
- **Fixed:**
:tacn:`zify` now handles :g:`Z.pow_pos` by default.
- In Coq 8.11, this was the case only when loading module
+ In |Coq| 8.11, this was the case only when loading module
:g:`ZifyPow` because this triggered a regression of :tacn:`lia`.
The regression is now fixed, and the module kept only for compatibility
(`#11362 <https://github.com/coq/coq/pull/11362>`_,
@@ -532,7 +532,7 @@ Flags, options and attributes
by Emilio Jesus Gallego Arias).
- **Removed:**
Unqualified ``polymorphic``, ``monomorphic``, ``template``,
- ``notemplate`` attributes (they were deprecated since Coq 8.10).
+ ``notemplate`` attributes (they were deprecated since |Coq| 8.10).
Use :attr:`universes(polymorphic)`, :attr:`universes(monomorphic)`,
:attr:`universes(template)` and :attr:`universes(notemplate)` instead
(`#11663 <https://github.com/coq/coq/pull/11663>`_, by Théo Zimmermann).
@@ -676,7 +676,7 @@ Tools
involving ``%``) (`#12126
<https://github.com/coq/coq/pull/12126>`_, by Jason Gross).
- **Changed:**
- When passing ``TIMED=1`` to ``make`` with either Coq's own makefile
+ When passing ``TIMED=1`` to ``make`` with either |Coq|'s own makefile
or a ``coq_makefile``\-made makefile, timing information is now
printed for OCaml files as well (`#12211
<https://github.com/coq/coq/pull/12211>`_, by Jason Gross).
@@ -701,7 +701,7 @@ Tools
<https://github.com/coq/coq/pull/12034>`_, by Gaëtan Gilbert).
- **Added:**
A new documentation environment ``details`` to make certain portion
- of a Coq document foldable. See :ref:`coqdoc-hide-show`
+ of a |Coq| document foldable. See :ref:`coqdoc-hide-show`
(`#10592 <https://github.com/coq/coq/pull/10592>`_,
by Thomas Letan).
- **Added:**
@@ -726,7 +726,7 @@ Tools
``--user``) to ``make`` (`#11302
<https://github.com/coq/coq/pull/11302>`_, by Jason Gross).
- **Added:**
- Coq's build system now supports both ``TIMING_FUZZ``,
+ |Coq|'s build system now supports both ``TIMING_FUZZ``,
``TIMING_SORT_BY``, and ``TIMING_REAL`` just like a ``Makefile``
made by ``coq_makefile`` (`#11302
<https://github.com/coq/coq/pull/11302>`_, by Jason Gross).
@@ -742,7 +742,7 @@ Tools
``TIMING_SORT_BY_MEM=1`` (to pass ``--sort-by-mem``) to ``make``
(`#11606 <https://github.com/coq/coq/pull/11606>`_, by Jason Gross).
- **Added:**
- Coq's build system now supports both ``TIMING_INCLUDE_MEM`` and
+ |Coq|'s build system now supports both ``TIMING_INCLUDE_MEM`` and
``TIMING_SORT_BY_MEM`` just like a ``Makefile`` made by
``coq_makefile`` (`#11606 <https://github.com/coq/coq/pull/11606>`_,
by Jason Gross).
@@ -765,7 +765,7 @@ Tools
(`#12091 <https://github.com/coq/coq/pull/12091>`_,
by Hugo Herbelin).
- **Fixed:**
- The various timing targets for Coq's standard library now correctly
+ The various timing targets for |Coq|'s standard library now correctly
display and label the "before" and "after" columns, rather than
mixing them up (`#11302 <https://github.com/coq/coq/pull/11302>`_
fixes `#11301 <https://github.com/coq/coq/issues/11301>`_, by Jason
@@ -799,15 +799,15 @@ Tools
<https://github.com/coq/coq/pull/12388>`_, fixes `#12387
<https://github.com/coq/coq/pull/12387>`_, by Jason Gross).
-CoqIDE
-^^^^^^
+|CoqIDE|
+^^^^^^^^
- **Removed:**
- "Tactic" menu from CoqIDE which had been unmaintained for a number of years
+ "Tactic" menu from |CoqIDE| which had been unmaintained for a number of years
(`#11414 <https://github.com/coq/coq/pull/11414>`_,
by Pierre-Marie Pédrot).
- **Removed:**
- "Revert all buffers" command from CoqIDE which had been broken for a long time
+ "Revert all buffers" command from |CoqIDE| which had been broken for a long time
(`#11415 <https://github.com/coq/coq/pull/11415>`_,
by Pierre-Marie Pédrot).
@@ -1038,7 +1038,7 @@ Extraction
- **Added:**
Support for better extraction of strings in OCaml and Haskell:
- `ExtOcamlNativeString` provides bindings from the Coq `String` type to
+ `ExtOcamlNativeString` provides bindings from the |Coq| `String` type to
the OCaml `string` type, and string literals can be extracted to literals,
both in OCaml and Haskell (`#10486
<https://github.com/coq/coq/pull/10486>`_, by Xavier Leroy, with help from
@@ -1063,7 +1063,7 @@ Reference manual
organization. In the new version, there are fewer top-level
chapters, and, in the HTML format, chapters are split into smaller
pages. This is still a work in progress and further restructuring
- is expected in the next versions of Coq
+ is expected in the next versions of |Coq|
(`CEP#43 <https://github.com/coq/ceps/pull/43>`_, implemented in
`#11601 <https://github.com/coq/coq/pull/11601>`_,
`#11871 <https://github.com/coq/coq/pull/11871>`_,
@@ -1076,7 +1076,7 @@ Reference manual
help and reviews of Jim Fehrle, Clément Pit-Claudel and others).
- **Changed:**
Most of the grammar is now presented using the notation mechanism
- that has been used to present commands and tactics since Coq 8.8 and
+ that has been used to present commands and tactics since |Coq| 8.8 and
which is documented in :ref:`syntax-conventions`
(`#11183 <https://github.com/coq/coq/pull/11183>`_,
`#11314 <https://github.com/coq/coq/pull/11314>`_,
@@ -1141,9 +1141,6 @@ Infrastructure and dependencies
Changes in 8.12.0
~~~~~~~~~~~~~~~~~~~~~
-.. contents::
- :local:
-
**Notations**
- **Added:**
@@ -1201,9 +1198,9 @@ Changes in 8.12.0
fixes `#11970 <https://github.com/coq/coq/issues/11970>`_,
by Pierre-Marie Pédrot).
-**CoqIDE**
+**|CoqIDE|**
-- **Fixed:** CoqIDE no longer exits when trying to open a file whose name is not a valid identifier
+- **Fixed:** |CoqIDE| no longer exits when trying to open a file whose name is not a valid identifier
(`#12562 <https://github.com/coq/coq/pull/12562>`_,
fixes `#10988 <https://github.com/coq/coq/issues/10988>`_,
by Vincent Laporte).
@@ -1216,6 +1213,116 @@ Changes in 8.12.0
modified in the meantime (`#12583 <https://github.com/coq/coq/pull/12583>`_,
fixes `#12582 <https://github.com/coq/coq/issues/12582>`_, by Jason Gross).
+Changes in 8.12.1
+~~~~~~~~~~~~~~~~~~~~~
+
+**Kernel**
+
+- **Fixed:** Incompleteness of conversion checking on problems
+ involving :ref:`eta-expansion` and :ref:`cumulative universe
+ polymorphic inductive types <cumulative>` (`#12738
+ <https://github.com/coq/coq/pull/12738>`_, fixes `#7015
+ <https://github.com/coq/coq/issues/7015>`_, by Gaëtan Gilbert).
+
+**Notations**
+
+- **Fixed:**
+ Undetected collision between a lonely notation and a notation in
+ scope at printing time
+ (`#12946 <https://github.com/coq/coq/pull/12946>`_,
+ fixes the first part of `#12908 <https://github.com/coq/coq/issues/12908>`_,
+ by Hugo Herbelin).
+- **Fixed:**
+ Printing of notations in custom entries with
+ variables not mentioning an explicit level
+ (`#13026 <https://github.com/coq/coq/pull/13026>`_,
+ fixes `#12775 <https://github.com/coq/coq/issues/12775>`_
+ and `#13018 <https://github.com/coq/coq/issues/13018>`_,
+ by Hugo Herbelin).
+
+**Tactics**
+
+- **Added:**
+ :tacn:`replace` and :tacn:`inversion` support registration of a
+ :g:`core.identity`\-like equality in :g:`Type`, such as HoTT's :g:`path`
+ (`#12847 <https://github.com/coq/coq/pull/12847>`_,
+ partially fixes `#12846 <https://github.com/coq/coq/issues/12846>`_,
+ by Hugo Herbelin).
+- **Fixed:**
+ Anomaly with :tacn:`injection` involving artificial
+ dependencies disappearing by reduction
+ (`#12816 <https://github.com/coq/coq/pull/12816>`_,
+ fixes `#12787 <https://github.com/coq/coq/issues/12787>`_,
+ by Hugo Herbelin).
+
+**Tactic language**
+
+- **Fixed:**
+ Miscellaneous issues with locating tactic errors
+ (`#13247 <https://github.com/coq/coq/pull/13247>`_,
+ fixes `#12773 <https://github.com/coq/coq/issues/12773>`_
+ and `#12992 <https://github.com/coq/coq/issues/12992>`_,
+ by Hugo Herbelin).
+
+**SSReflect**
+
+- **Fixed:**
+ Regression in error reporting after :tacn:`case <case (ssreflect)>`.
+ A generic error message "Could not fill dependent hole in apply" was
+ reported for any error following :tacn:`case <case (ssreflect)>` or
+ :tacn:`elim <elim (ssreflect)>`
+ (`#12857 <https://github.com/coq/coq/pull/12857>`_,
+ fixes `#12837 <https://github.com/coq/coq/issues/12837>`_,
+ by Enrico Tassi).
+
+**Commands and options**
+
+- **Fixed:**
+ Failures of :cmd:`Search` in the presence of primitive projections
+ (`#13301 <https://github.com/coq/coq/pull/13301>`_,
+ fixes `#13298 <https://github.com/coq/coq/issues/13298>`_,
+ by Hugo Herbelin).
+
+**Tools**
+
+- **Fixed:**
+ Special symbols now escaped in the index produced by coqdoc,
+ avoiding collision with the syntax of the output format
+ (`#12754 <https://github.com/coq/coq/pull/12754>`_,
+ fixes `#12752 <https://github.com/coq/coq/issues/12752>`_,
+ by Hugo Herbelin).
+- **Fixed:**
+ The `details` environment added in the 8.12 release can now be used
+ as advertised in the reference manual
+ (`#12772 <https://github.com/coq/coq/pull/12772>`_,
+ by Thomas Letan).
+- **Fixed:**
+ Targets such as ``print-pretty-timed`` in ``coq_makefile``\-made
+ ``Makefile``\s no longer error in rare cases where ``--output-sync`` is not
+ passed to make and the timing output gets interleaved in just the wrong way
+ (`#13063 <https://github.com/coq/coq/pull/13063>`_, fixes `#13062
+ <https://github.com/coq/coq/issues/13062>`_, by Jason Gross).
+
+**CoqIDE**
+
+- **Fixed:**
+ View menu "Display parentheses"
+ (`#12794 <https://github.com/coq/coq/pull/12794>`_ and `#13067 <https://github.com/coq/coq/pull/13067>`_,
+ fixes `#12793 <https://github.com/coq/coq/issues/12793>`_,
+ by Jean-Christophe Léchenet and Hugo Herbelin).
+
+**Infrastructure and dependencies**
+
+- **Added:**
+ Coq is now tested against OCaml 4.11.1
+ (`#12972 <https://github.com/coq/coq/pull/12972>`_,
+ by Emilio Jesus Gallego Arias).
+- **Fixed:**
+ The reference manual can now build with Sphinx 3
+ (`#13011 <https://github.com/coq/coq/pull/13011>`_,
+ fixes `#12332 <https://github.com/coq/coq/issues/12332>`_,
+ by Théo Zimmermann and Jim Fehrle).
+
Version 8.11
------------
@@ -1250,7 +1357,7 @@ The main changes brought by |Coq| version 8.11 are:
instances of the constructive and classical real numbers.
Additionally, while the :tacn:`omega` tactic is not yet deprecated in
-this version of Coq, it should soon be the case and we already
+this version of |Coq|, it should soon be the case and we already
recommend users to switch to :tacn:`lia` in new proof scripts (see
also the warning message in the :ref:`corresponding chapter
<omega_chapter>`).
@@ -1260,7 +1367,7 @@ of |Coq| and affected releases. See the `Changes in 8.11+beta1`_
section and following sections for the detailed list of changes,
including potentially breaking changes marked with **Changed**.
-Coq's documentation is available at https://coq.github.io/doc/v8.11/api (documentation of
+|Coq|'s documentation is available at https://coq.github.io/doc/v8.11/api (documentation of
the ML API), https://coq.github.io/doc/v8.11/refman (reference
manual), and https://coq.github.io/doc/v8.11/stdlib (documentation of
the standard library).
@@ -1322,7 +1429,7 @@ Changes in 8.11+beta1
computation. Primitive floats are added in the language of terms,
following the binary64 format of the IEEE 754 standard, and the
related operations are implemented for the different reduction
- engines of Coq by using the corresponding processor operators in
+ engines of |Coq| by using the corresponding processor operators in
rounding-to-nearest-even. The properties of these operators are
axiomatized in the theory :g:`Coq.Floats.FloatAxioms` which is part
of the library :g:`Coq.Floats.Floats`.
@@ -1415,7 +1522,7 @@ Changes in 8.11+beta1
Output of the :cmd:`Print` and :cmd:`About` commands.
Arguments meta-data is now displayed as the corresponding
:cmd:`Arguments` command instead of the
- human-targeted prose used in previous Coq versions. (`#10985
+ human-targeted prose used in previous |Coq| versions. (`#10985
<https://github.com/coq/coq/pull/10985>`_, by Gaëtan Gilbert).
.. _811RefineInstance:
@@ -1463,8 +1570,8 @@ Changes in 8.11+beta1
A simplification of parsing rules could cause a slight change of
parsing precedences for the very rare users who defined notations
with `constr` at level strictly between 100 and 200 and used these
- notations on the right-hand side of a cast operator (`:`, `:>`,
- `:>>`) (`#10963 <https://github.com/coq/coq/pull/10963>`_, by Théo
+ notations on the right-hand side of a cast operator (`:`, `<:`,
+ `<<:`) (`#10963 <https://github.com/coq/coq/pull/10963>`_, by Théo
Zimmermann, simplification initially noticed by Jim Fehrle).
**Tactics**
@@ -1514,7 +1621,7 @@ Changes in 8.11+beta1
- **Added:**
Ltac2, a new version of the tactic language Ltac, that doesn't
- preserve backward compatibility, has been integrated in the main Coq
+ preserve backward compatibility, has been integrated in the main |Coq|
distribution. It is still experimental, but we already recommend
users of advanced Ltac to start using it and report bugs or request
enhancements. See its documentation in the :ref:`dedicated chapter
@@ -1543,14 +1650,14 @@ Changes in 8.11+beta1
Generalize tactics :tacn:`under` and :tacn:`over` for any registered
relation. More precisely, assume the given context lemma has type
`forall f1 f2, .. -> (forall i, R1 (f1 i) (f2 i)) -> R2 f1 f2`. The
- first step performed by :tacn:`under` (since Coq 8.10) amounts to
+ first step performed by :tacn:`under` (since |Coq| 8.10) amounts to
calling the tactic :tacn:`rewrite <rewrite (ssreflect)>`, which
itself relies on :tacn:`setoid_rewrite` if need be. So this step was
already compatible with a double implication or setoid equality for
the conclusion head symbol `R2`. But a further step consists in
tagging the generated subgoal `R1 (f1 i) (?f2 i)` to protect it from
unwanted evar instantiation, and get `Under_rel _ R1 (f1 i) (?f2 i)`
- that is displayed as ``'Under[ f1 i ]``. In Coq 8.10, this second
+ that is displayed as ``'Under[ f1 i ]``. In |Coq| 8.10, this second
(convenience) step was only performed when `R1` was Leibniz' `eq` or
`iff`. Now, it is also performed for any relation `R1` which has a
``RewriteRelation`` instance (a `RelationClasses.Reflexive` instance
@@ -1612,7 +1719,7 @@ Changes in 8.11+beta1
.. warning::
This is a common source of incompatibilities in projects
- migrating to Coq 8.11.
+ migrating to |Coq| 8.11.
- **Changed:**
Output generated by :flag:`Printing Dependent Evars Line` flag
@@ -1643,7 +1750,7 @@ Changes in 8.11+beta1
`coqc` now provides the ability to generate compiled interfaces.
Use `coqc -vos foo.v` to skip all opaque proofs during the
compilation of `foo.v`, and output a file called `foo.vos`.
- This feature is experimental. It enables working on a Coq file without the need to
+ This feature is experimental. It enables working on a |Coq| file without the need to
first compile the proofs contained in its dependencies
(`#8642 <https://github.com/coq/coq/pull/8642>`_ by Arthur Charguéraud, review by
Maxime Dénès and Emilio Gallego).
@@ -1715,7 +1822,7 @@ Changes in 8.11+beta1
**Infrastructure and dependencies**
- **Changed:**
- Coq now officially supports OCaml 4.08.
+ |Coq| now officially supports OCaml 4.08.
See `INSTALL` file for details
(`#10471 <https://github.com/coq/coq/pull/10471>`_,
by Emilio Jesús Gallego Arias).
@@ -1793,7 +1900,7 @@ Changes in 8.11.0
**Tactic language**
- **Fixed:**
- Syntax of tactic `cofix ... with ...` was broken since Coq 8.10
+ Syntax of tactic `cofix ... with ...` was broken since |Coq| 8.10
(`#11241 <https://github.com/coq/coq/pull/11241>`_,
by Hugo Herbelin).
@@ -1826,9 +1933,9 @@ Changes in 8.11.0
fixes `#11353 <https://github.com/coq/coq/issues/11353>`_,
by Karl Palmskog).
-**CoqIDE**
+**|CoqIDE|**
-- **Changed:** CoqIDE now uses the GtkSourceView native implementation
+- **Changed:** |CoqIDE| now uses the GtkSourceView native implementation
of the autocomplete mechanism (`#11400
<https://github.com/coq/coq/pull/11400>`_, by Pierre-Marie Pédrot).
@@ -1874,7 +1981,7 @@ Changes in 8.11.1
(`#11859 <https://github.com/coq/coq/pull/11859>`_,
by Pierre Roux).
-**CoqIDE**
+**|CoqIDE|**
- **Fixed:**
Compiling file paths containing spaces
@@ -1932,21 +2039,21 @@ Changes in 8.11.2
(`#12070 <https://github.com/coq/coq/pull/12070>`_,
by Pierre Roux).
-**CoqIDE**
+**|CoqIDE|**
- **Changed:**
- CoqIDE now uses native window frames by default on Windows.
+ |CoqIDE| now uses native window frames by default on Windows.
The GTK window frames can be restored by setting the `GTK_CSD` environment variable to `1`
(`#12060 <https://github.com/coq/coq/pull/12060>`_,
fixes `#11080 <https://github.com/coq/coq/issues/11080>`_,
by Attila Gáspár).
- **Fixed:**
- New patch presumably fixing the random Coq 8.11 segfault issue with CoqIDE completion
+ New patch presumably fixing the random |Coq| 8.11 segfault issue with |CoqIDE| completion
(`#12068 <https://github.com/coq/coq/pull/12068>`_,
by Hugo Herbelin, presumably fixing
`#11943 <https://github.com/coq/coq/pull/11943>`_).
- **Fixed:**
- Highlighting style consistently applied to all three buffers of CoqIDE
+ Highlighting style consistently applied to all three buffers of |CoqIDE|
(`#12106 <https://github.com/coq/coq/pull/12106>`_,
by Hugo Herbelin; fixes
`#11506 <https://github.com/coq/coq/pull/11506>`_).
@@ -2058,15 +2165,15 @@ reference manual. Here are the most important user-visible changes:
:math:`\Type`. It used to be limited to sort `Prop`
(`#7634 <https://github.com/coq/coq/pull/7634>`_, by Théo Winterhalter).
-- A new registration mechanism for reference from ML code to Coq
+- A new registration mechanism for reference from ML code to |Coq|
constructs has been added
(`#186 <https://github.com/coq/coq/pull/186>`_,
by Emilio Jesús Gallego Arias, Maxime Dénès and Vincent Laporte).
-- CoqIDE:
+- |CoqIDE|:
- - CoqIDE now depends on gtk+3 and lablgtk3 instead of gtk+2 and lablgtk2.
- The INSTALL file available in the Coq sources has been updated to list
+ - |CoqIDE| now depends on gtk+3 and lablgtk3 instead of gtk+2 and lablgtk2.
+ The INSTALL file available in the |Coq| sources has been updated to list
the new dependencies
(`#9279 <https://github.com/coq/coq/pull/9279>`_,
by Hugo Herbelin, with help from Jacques Garrigue,
@@ -2081,15 +2188,15 @@ reference manual. Here are the most important user-visible changes:
- Infrastructure and dependencies:
- - Coq 8.10 requires OCaml >= 4.05.0, bumped from 4.02.3 See the
+ - |Coq| 8.10 requires OCaml >= 4.05.0, bumped from 4.02.3 See the
`INSTALL` file for more information on dependencies
(`#7522 <https://github.com/coq/coq/pull/7522>`_, by Emilio Jesús Gallego Arías).
- - Coq 8.10 doesn't need Camlp5 to build anymore. It now includes a
- fork of the core parsing library that Coq uses, which is a small
+ - |Coq| 8.10 doesn't need Camlp5 to build anymore. It now includes a
+ fork of the core parsing library that |Coq| uses, which is a small
subset of the whole Camlp5 distribution. In particular, this subset
doesn't depend on the OCaml AST, allowing easier compilation and
- testing on experimental OCaml versions. Coq also ships a new parser
+ testing on experimental OCaml versions. |Coq| also ships a new parser
`coqpp` that plugin authors must switch to
(`#7902 <https://github.com/coq/coq/pull/7902>`_,
`#7979 <https://github.com/coq/coq/pull/7979>`_,
@@ -2098,19 +2205,19 @@ reference manual. Here are the most important user-visible changes:
and `#8945 <https://github.com/coq/coq/pull/8945>`_,
by Pierre-Marie Pédrot and Emilio Jesús Gallego Arias).
- The Coq developers would like to thank Daniel de Rauglaudre for many
+ The |Coq| developers would like to thank Daniel de Rauglaudre for many
years of continued support.
- - Coq now supports building with Dune, in addition to the traditional
+ - |Coq| now supports building with Dune, in addition to the traditional
Makefile which is scheduled for deprecation
(`#6857 <https://github.com/coq/coq/pull/6857>`_,
by Emilio Jesús Gallego Arias, with help from Rudi Grinberg).
- Experimental support for building Coq projects has been integrated
+ Experimental support for building |Coq| projects has been integrated
in Dune at the same time, providing an `improved experience
<https://coq.discourse.group/t/a-guide-to-building-your-coq-libraries-and-plugins-with-dune/>`_
for plugin developers. We thank the Dune team for their work
- supporting Coq.
+ supporting |Coq|.
Version 8.10 also comes with a bunch of smaller-scale changes and
improvements regarding the different components of the system, including
@@ -2129,10 +2236,10 @@ contributions from Gaëtan Gilbert, Pierre-Marie Pédrot, and Maxime Dénès.
Maxime Dénès, Emilio Jesús Gallego Arias, Gaëtan Gilbert, Michael
Soegtrop, Théo Zimmermann worked on maintaining and improving the
continuous integration system and package building infrastructure.
-Coq is now continuously tested against OCaml trunk, in addition to the
+|Coq| is now continuously tested against the |OCaml| trunk, in addition to the
oldest supported and latest OCaml releases.
-Coq's documentation for the development branch is now deployed
+|Coq|'s documentation for the development branch is now deployed
continuously at https://coq.github.io/doc/master/api (documentation of
the ML API), https://coq.github.io/doc/master/refman (reference
manual), and https://coq.github.io/doc/master/stdlib (documentation of
@@ -2191,13 +2298,13 @@ Other changes in 8.10+beta1
(*à la* ``-top``) based on the filename passed, taking into account the
proper ``-R``/``-Q`` options. For example, given ``-R Foo foolib`` using
``-topfile foolib/bar.v`` will set the module name to ``Foo.Bar``.
- CoqIDE now properly sets the module name for a given file based on
+ |CoqIDE| now properly sets the module name for a given file based on
its path
(`#8991 <https://github.com/coq/coq/pull/8991>`_,
closes `#8989 <https://github.com/coq/coq/issues/8989>`_,
by Gaëtan Gilbert).
- - Experimental: Coq flags and options can now be set on the
+ - Experimental: |Coq| flags and options can now be set on the
command-line, e.g. ``-set "Universe Polymorphism=true"``
(`#9876 <https://github.com/coq/coq/pull/9876>`_, by Gaëtan Gilbert).
@@ -2295,7 +2402,7 @@ Other changes in 8.10+beta1
- Deprecated compatibility notations have actually been
removed. Uses of these notations are generally easy to fix thanks
- to the hint contained in the deprecation warning emitted by Coq
+ to the hint contained in the deprecation warning emitted by |Coq|
8.8 and 8.9. For projects that require more than a handful of
such fixes, there is `a script
<https://gist.github.com/JasonGross/9770653967de3679d131c59d42de6d17#file-replace-notations-py>`_
@@ -2310,7 +2417,7 @@ Other changes in 8.10+beta1
- The `quote plugin
<https://coq.inria.fr/distrib/V8.9.0/refman/proof-engine/detailed-tactic-examples.html#quote>`_
was removed. If some users are interested in maintaining this plugin
- externally, the Coq development team can provide assistance for
+ externally, the |Coq| development team can provide assistance for
extracting the plugin and setting up a new repository
(`#7894 <https://github.com/coq/coq/pull/7894>`_, by Maxime Dénès).
@@ -2537,7 +2644,7 @@ Other changes in 8.10+beta1
- Changelog has been moved from a specific file `CHANGES.md` to the
reference manual; former Credits chapter of the reference manual has
been split in two parts: a History chapter which was enriched with
- additional historical information about Coq versions 1 to 5, and a
+ additional historical information about |Coq| versions 1 to 5, and a
Changes chapter which was enriched with the content formerly in
`CHANGES.md` and `COMPATIBILITY`
(`#9133 <https://github.com/coq/coq/pull/9133>`_,
@@ -2580,15 +2687,15 @@ Many bug fixes and documentation improvements, in particular:
fixes `#9336 <https://github.com/coq/coq/issues/9336>`_,
by Andreas Lynge, review by Enrico Tassi)
-**CoqIDE**
+**|CoqIDE|**
-- Fix CoqIDE instability on Windows after the update to gtk3
+- Fix |CoqIDE| instability on Windows after the update to gtk3
(`#10360 <https://github.com/coq/coq/pull/10360>`_, by Michael Soegtrop,
closes `#9885 <https://github.com/coq/coq/issues/9885>`_).
**Miscellaneous**
-- Proof General can now display Coq-generated diffs between proof steps
+- Proof General can now display |Coq|-generated diffs between proof steps
in color
(`#10019 <https://github.com/coq/coq/pull/10019>`_ and
(in Proof General) `#421 <https://github.com/ProofGeneral/PG/pull/421>`_,
@@ -2696,7 +2803,7 @@ A few bug fixes and documentation improvements, in particular:
fixes `#10894 <https://github.com/coq/coq/issues/10894>`_,
by Hugo Herbelin).
-**CoqIDE**
+**|CoqIDE|**
- Fix handling of unicode input before space
(`#10852 <https://github.com/coq/coq/pull/10852>`_,
@@ -2736,9 +2843,9 @@ Changes in 8.10.2
(`#11090 <https://github.com/coq/coq/pull/11090>`_,
fixes `#11033 <https://github.com/coq/coq/issues/11033>`_, by Hugo Herbelin).
-**CoqIDE**
+**|CoqIDE|**
-- Fixed uneven dimensions of CoqIDE panels when window has been resized
+- Fixed uneven dimensions of |CoqIDE| panels when window has been resized
(`#11070 <https://github.com/coq/coq/pull/11070>`_,
fixes 8.10-regression `#10956 <https://github.com/coq/coq/issues/10956>`_,
by Guillaume Melquiond).
@@ -2853,7 +2960,7 @@ important ones are documented in the next subsection file.
On the implementation side, the ``dev/doc/changes.md`` file documents
the numerous changes to the implementation and improvements of
interfaces. The file provides guidelines on porting a plugin to the new
-version and a plugin development tutorial kept in sync with Coq was
+version and a plugin development tutorial kept in sync with |Coq| was
introduced by Yves Bertot http://github.com/ybertot/plugin_tutorials.
The new ``dev/doc/critical-bugs`` file documents the known critical bugs
of |Coq| and affected releases.
@@ -2917,7 +3024,7 @@ Notations
entries" (see chapter "Syntax extensions" of the reference manual).
- Deprecated compatibility notations will actually be removed in the
- next version of Coq. Uses of these notations are generally easy to
+ next version of |Coq|. Uses of these notations are generally easy to
fix thanks to the hint contained in the deprecation warnings. For
projects that require more than a handful of such fixes, there is `a
script
@@ -3018,7 +3125,7 @@ Standard Library
- Numeral syntax for `nat` is no longer available without loading the
entire prelude (`Require Import Coq.Init.Prelude`). This only
- impacts users running Coq without the init library (`-nois` or
+ impacts users running |Coq| without the init library (`-nois` or
`-noinit`) and also issuing `Require Import Coq.Init.Datatypes`.
Tools
@@ -3028,10 +3135,10 @@ Tools
`COQFLAGS` is now entirely separate from `COQLIBS`, so in custom Makefiles
`$(COQFLAGS)` should be replaced by `$(COQFLAGS) $(COQLIBS)`.
-- Removed the `gallina` utility (extracts specification from Coq vernacular files).
+- Removed the `gallina` utility (extracts specification from |Coq| vernacular files).
If you would like to maintain this tool externally, please contact us.
-- Removed the Emacs modes distributed with Coq. You are advised to
+- Removed the Emacs modes distributed with |Coq|. You are advised to
use `Proof-General <https://proofgeneral.github.io/>`_ (and optionally
`Company-Coq <https://github.com/cpitclaudel/company-coq>`_) instead.
If your use case is not covered by these alternative Emacs modes,
@@ -3060,15 +3167,15 @@ Vernacular Commands
NoTCResolution`.
- Multiple sections with the same name are allowed.
-Coq binaries and process model
+|Coq| binaries and process model
-- Before 8.9, Coq distributed a single `coqtop` binary and a set of
+- Before 8.9, |Coq| distributed a single `coqtop` binary and a set of
dynamically loadable plugins that used to take over the main loop
for tasks such as IDE language server or parallel proof checking.
These plugins have been turned into full-fledged binaries so each
different process has associated a particular binary now, in
- particular `coqidetop` is the CoqIDE language server, and
+ particular `coqidetop` is the |CoqIDE| language server, and
`coq{proof,tactic,query}worker` are in charge of task-specific and
parallel proof checking.
@@ -3126,7 +3233,7 @@ Changes in 8.8.1
- Some quality-of-life fixes.
- Numerous improvements to the documentation.
- Fix a critical bug related to primitive projections and :tacn:`native_compute`.
-- Ship several additional Coq libraries with the Windows installer.
+- Ship several additional |Coq| libraries with the Windows installer.
Version 8.8
-----------
@@ -3232,7 +3339,7 @@ of everybody who to some extent influenced the development.
The |Coq| consortium, an organization directed towards users and
supporters of the system, is now running and employs Maxime Dénès.
-The contacts of the Coq Consortium are Yves Bertot and Maxime Dénès.
+The contacts of the |Coq| Consortium are Yves Bertot and Maxime Dénès.
| Santiago de Chile, March 2018,
| Matthieu Sozeau for the |Coq| development team
@@ -3354,7 +3461,7 @@ Universes
Tools
-- Coq can now be run with the option -mangle-names to change the auto-generated
+- |Coq| can now be run with the option -mangle-names to change the auto-generated
name scheme. This is intended to function as a linter for developments that
want to be robust to changes in auto-generated names. This feature is experimental,
and may change or disappear without warning.
@@ -3364,7 +3471,7 @@ Checker
- The checker now accepts filenames in addition to logical paths.
-CoqIDE
+|CoqIDE|
- Find and Replace All report the number of occurrences found; Find indicates
when it wraps.
@@ -3377,7 +3484,7 @@ coqdep
Documentation
-- The Coq FAQ, formerly located at https://coq.inria.fr/faq, has been
+- The |Coq| FAQ, formerly located at https://coq.inria.fr/faq, has been
moved to the GitHub wiki section of this repository; the main entry
page is https://github.com/coq/coq/wiki/The-Coq-FAQ.
- Documentation: a large community effort resulted in the migration
@@ -3427,7 +3534,7 @@ Details of changes in 8.8.0
Tools
- Asynchronous proof delegation policy was fixed. Since version 8.7
- Coq was ignoring previous runs and the `-async-proofs-delegation-threshold`
+ |Coq| was ignoring previous runs and the `-async-proofs-delegation-threshold`
option did not have the expected behavior.
Tactic language
@@ -3700,7 +3807,7 @@ Vernacular Commands
- Possibility to unset the printing of notations in a more fine grained
fashion than `Unset Printing Notations` is provided without any
user-syntax. The goal is that someone creates a plugin to experiment
- such a user-syntax, to be later integrated in Coq when stabilized.
+ such a user-syntax, to be later integrated in |Coq| when stabilized.
- `About` now tells if a reference is a coercion.
- The deprecated `Save` vernacular and its form `Save Theorem id` to
close proofs have been removed from the syntax. Please use `Qed`.
@@ -3718,7 +3825,7 @@ Standard Library
- New lemmas about iff and about orders on positive and Z.
- New lemmas on powerRZ.
- Strengthened statement of JMeq_eq_dep (closes bug #4912).
-- The BigN, BigZ, BigZ libraries are no longer part of the Coq standard
+- The BigN, BigZ, BigZ libraries are no longer part of the |Coq| standard
library, they are now provided by a separate repository
https://github.com/coq/bignums
The split has been done just after the Int31 library.
@@ -3732,12 +3839,12 @@ Standard Library
Plugins
-- The Ssreflect plugin is now distributed with Coq. Its documentation has
+- The Ssreflect plugin is now distributed with |Coq|. Its documentation has
been integrated as a chapter of the reference manual. This chapter is
work in progress so feedback is welcome.
- The mathematical proof language (also known as declarative mode) was removed.
- A new command Extraction TestCompile has been introduced, not meant
- for the general user but instead for Coq's test-suite.
+ for the general user but instead for |Coq|'s test-suite.
- The extraction plugin is no longer loaded by default. It must be
explicitly loaded with [Require Extraction], which is backwards
compatible.
@@ -3756,7 +3863,7 @@ Tools
the extensibility of generated Makefiles, and to make _CoqProject files
more palatable to IDEs. Overview:
- * _CoqProject files contain only Coq specific data (i.e. the list of
+ * _CoqProject files contain only |Coq| specific data (i.e. the list of
files, -R options, ...)
* coq_makefile translates _CoqProject to Makefile.conf and copies in the
desired location a standard Makefile (that reads Makefile.conf)
@@ -3814,15 +3921,15 @@ Details of changes in 8.7+beta2
Tools
-- In CoqIDE, the "Compile Buffer" command takes account of flags in
+- In |CoqIDE|, the "Compile Buffer" command takes account of flags in
_CoqProject or other project file.
Improvements around some error messages.
Many bug fixes including two important ones:
-- Bug #5730: CoqIDE becomes unresponsive on file open.
-- coq_makefile: make sure compile flags for Coq and coq_makefile are in sync
+- Bug #5730: |CoqIDE| becomes unresponsive on file open.
+- coq_makefile: make sure compile flags for |Coq| and coq_makefile are in sync
(in particular, make sure the `-safe-string` option is used to compile plugins).
Details of changes in 8.7.0
@@ -3833,7 +3940,7 @@ OCaml
- Users can pass specific flags to the OCaml optimizing compiler by
-using the flambda-opts configure-time option.
- Beware that compiling Coq with a flambda-enabled compiler is
+ Beware that compiling |Coq| with a flambda-enabled compiler is
experimental and may require large amounts of RAM and CPU, see
INSTALL for more details.
@@ -3863,7 +3970,7 @@ Version 8.6
Summary of changes
~~~~~~~~~~~~~~~~~~
-Coq version 8.6 contains the result of refinements, stabilization of
+|Coq| version 8.6 contains the result of refinements, stabilization of
8.5’s features and cleanups of the internals of the system. Over the
year of (now time-based) development, about 450 bugs were resolved and
over 100 contributions integrated. The main user visible changes are:
@@ -3897,7 +4004,7 @@ over 100 contributions integrated. The main user visible changes are:
- Integration of LtacProf, a profiler for Ltac by Jason Gross, Paul
Steckler, Enrico Tassi and Tobias Tebbi.
-Coq 8.6 also comes with a bunch of smaller-scale changes and
+|Coq| 8.6 also comes with a bunch of smaller-scale changes and
improvements regarding the different components of the system. We shall
only list a few of them.
@@ -3983,13 +4090,13 @@ development.
Version 8.6 is the first release of |Coq| developed on a time-based
development cycle. Its development spanned 10 months from the release of
-Coq 8.5 and was based on a public roadmap. To date, it contains more
+|Coq| 8.5 and was based on a public roadmap. To date, it contains more
external contributions than any previous |Coq| system. Code reviews were
systematically done before integration of new features, with an
important focus given to compatibility and performance issues, resulting
in a hopefully more robust release than |Coq| 8.5.
-Coq Enhancement Proposals (CEPs for short) were introduced by Enrico
+|Coq| Enhancement Proposals (CEPs for short) were introduced by Enrico
Tassi to provide more visibility and a discussion period on new
features, they are publicly available https://github.com/coq/ceps.
@@ -4134,13 +4241,13 @@ General infrastructure
- New configurable warning system which can be controlled with the vernacular
command "Set Warnings", or, under coqc/coqtop, with the flag "-w". In
particular, the default is now that warnings are printed by coqc.
-- In asynchronous mode, Coq is now capable of recovering from errors and
+- In asynchronous mode, |Coq| is now capable of recovering from errors and
continue processing the document.
Tools
- coqc accepts a -o option to specify the output file name
-- coqtop accepts --print-version to print Coq and OCaml versions in
+- coqtop accepts --print-version to print |Coq| and |OCaml| versions in
easy to parse format
- Setting [Printing Dependent Evars Line] can be unset to disable the
computation associated with printing the "dependent evars: " line in
@@ -4169,7 +4276,7 @@ Other bug fixes in universes, type class shelving,...
Details of changes in 8.6.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Fix #5380: Default colors for CoqIDE are actually applied.
+- Fix #5380: Default colors for |CoqIDE| are actually applied.
- Fix plugin warnings
- Document named evars (including Show ident)
- Fix Bug #5574, document function scope
@@ -4221,7 +4328,7 @@ Version 8.5
Summary of changes
~~~~~~~~~~~~~~~~~~
-Coq version 8.5 contains the result of five specific long-term projects:
+|Coq| version 8.5 contains the result of five specific long-term projects:
- A new asynchronous evaluation and compilation mode by Enrico Tassi
with help from Bruno Barras and Carst Tankink.
@@ -4312,7 +4419,7 @@ conversion test and normal form computation using the OCaml native
compiler. It complements the virtual machine conversion offering much
faster computation for expensive functions.
-Coq 8.5 also comes with a bunch of many various smaller-scale changes
+|Coq| 8.5 also comes with a bunch of many various smaller-scale changes
and improvements regarding the different components of the system. We
shall only list a few of them.
@@ -4375,8 +4482,8 @@ Tankink. Maxime Dénès coordinated the release process.
Potential sources of incompatibilities
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-List of typical changes to be done to adapt files from Coq 8.4
-to Coq 8.5 when not using compatibility option ``-compat 8.4``.
+List of typical changes to be done to adapt files from |Coq| 8.4
+to |Coq| 8.5 when not using compatibility option ``-compat 8.4``.
- Symptom: "The reference omega was not found in the current environment".
@@ -4511,7 +4618,7 @@ Logic
logic inconsistent).
- The guard condition for fixpoints is now a bit stricter. Propagation
of subterm value through pattern matching is restricted according to
- the return predicate. Restores compatibility of Coq's logic with the
+ the return predicate. Restores compatibility of |Coq|'s logic with the
propositional extensionality axiom. May create incompatibilities in
recursive programs heavily using dependent types.
- Trivial inductive types are no longer defined in Type but in Prop, which
@@ -4551,7 +4658,7 @@ Vernacular commands
- A new Print Strategies command allows visualizing the opacity status
of the whole engine.
- The "Locate" command now searches through all sorts of qualified namespaces of
- Coq: terms, modules, tactics, etc. The old behavior of the command can be
+ |Coq|: terms, modules, tactics, etc. The old behavior of the command can be
retrieved using the "Locate Term" command.
- New "Derive" command to help writing program by derivation.
- New "Refine Instance Mode" option that allows to deactivate the generation of
@@ -4879,24 +4986,24 @@ Tools
files from the quickly generated proofs.
- The XML plugin was discontinued and removed from the source.
- A new utility called coqworkmgr can be used to limit the number of
- concurrent workers started by independent processes, like make and CoqIDE.
+ concurrent workers started by independent processes, like make and |CoqIDE|.
This is of interest for users of the par: goal selector.
Interfaces
-- CoqIDE supports asynchronous edition of the document, ongoing tasks and
+- |CoqIDE| supports asynchronous edition of the document, ongoing tasks and
errors are reported in the bottom right window. The number of workers
taking care of processing proofs can be selected with -async-proofs-j.
-- CoqIDE highlights in yellow "unsafe" commands such as axiom
+- |CoqIDE| highlights in yellow "unsafe" commands such as axiom
declarations, and tactics like "give_up".
-- CoqIDE supports Proof General like key bindings;
+- |CoqIDE| supports Proof General like key bindings;
to activate the PG mode go to Edit -> Preferences -> Editor.
For the documentation see Help -> Help for PG mode.
-- CoqIDE automatically retracts the locked area when one edits the
+- |CoqIDE| automatically retracts the locked area when one edits the
locked text.
-- CoqIDE search and replace got regular expressions power. See the
+- |CoqIDE| search and replace got regular expressions power. See the
documentation of OCaml's Str module for the supported syntax.
-- Many CoqIDE windows, including the query one, are now detachable to
+- Many |CoqIDE| windows, including the query one, are now detachable to
improve usability on multi screen work stations.
- Coqtop/coqc outputs highlighted syntax. Colors can be configured thanks
to the COQ_COLORS environment variable, and their current state can
@@ -4907,7 +5014,7 @@ Interfaces
Internal Infrastructure
- Many reorganizations in the ocaml source files. For instance,
- many internal a.s.t. of Coq are now placed in mli files in
+ many internal a.s.t. of |Coq| are now placed in mli files in
a new directory intf/, for instance constrexpr.mli or glob_term.mli.
More details in dev/doc/changes.
@@ -4959,7 +5066,7 @@ Tactics
Extraction
- Definitions extracted to Haskell GHC should no longer randomly
- segfault when some Coq types cannot be represented by Haskell types.
+ segfault when some |Coq| types cannot be represented by Haskell types.
- Definitions can now be extracted to Json for post-processing.
Tools
@@ -5057,8 +5164,8 @@ Tools
Standard Library
- There is now a Coq.Compat.Coq84 library, which sets the various compatibility
- options and does a few redefinitions to make Coq behave more like Coq v8.4.
- The standard way of putting Coq in v8.4 compatibility mode is to pass the command
+ options and does a few redefinitions to make |Coq| behave more like |Coq| v8.4.
+ The standard way of putting |Coq| in v8.4 compatibility mode is to pass the command
line flags "-require Coq.Compat.Coq84 -compat 8.4".
Details of changes in 8.5
@@ -5067,7 +5174,7 @@ Details of changes in 8.5
Tools
- Flag "-compat 8.4" now loads Coq.Compat.Coq84. The standard way of
- putting Coq in v8.4 compatibility mode is to pass the command line flag
+ putting |Coq| in v8.4 compatibility mode is to pass the command line flag
"-compat 8.4". It can be followed by "-require Coq.Compat.AdmitAxiom"
if the 8.4 behavior of admit is needed, in which case it uses an axiom.
@@ -5108,7 +5215,7 @@ Various performance improvements (time, space used by .vo files)
Other bugfixes
- Fix order of arguments to Big.compare_case in ExtrOcamlZBigInt.v
-- Added compatibility coercions from Specif.v which were present in Coq 8.4.
+- Added compatibility coercions from Specif.v which were present in |Coq| 8.4.
- Fixing a source of inefficiency and an artificial dependency in the printer in the congruence tactic.
- Allow to unset the refinement mode of Instance in ML
- Fixing an incorrect use of prod_appvect on a term which was not a product in setoid_rewrite.
@@ -5123,7 +5230,7 @@ Other bugfixes
- #4623: set tactic too weak with universes (regression)
- Fix incorrect behavior of CS resolution
- #4591: Uncaught exception in directory browsing.
-- CoqIDE is more resilient to initialization errors.
+- |CoqIDE| is more resilient to initialization errors.
- #4614: "Fully check the document" is uninterruptible.
- Try eta-expansion of records only on non-recursive ones
- Fix bug when a sort is ascribed to a Record
@@ -5133,23 +5240,23 @@ Other bugfixes
- Fix strategy of Keyed Unification
- #4608: Anomaly "output_value: abstract value (outside heap)".
- #4607: do not read native code files if native compiler was disabled.
-- #4105: poor escaping in the protocol between CoqIDE and coqtop.
+- #4105: poor escaping in the protocol between |CoqIDE| and coqtop.
- #4596: [rewrite] broke in the past few weeks.
- #4533 (partial): respect declared global transparency of projections in unification.ml
- #4544: Backtrack on using full betaiota reduction during keyed unification.
-- #4540: CoqIDE bottom progress bar does not update.
+- #4540: |CoqIDE| bottom progress bar does not update.
- Fix regression from 8.4 in reflexivity
- #4580: [Set Refine Instance Mode] also used for Program Instance.
- #4582: cannot override notation [ x ]. MAY CREATE INCOMPATIBILITIES, see #4683.
- STM: Print/Extraction have to be skipped if -quick
-- #4542: CoqIDE: STOP button also stops workers
+- #4542: |CoqIDE|: STOP button also stops workers
- STM: classify some variants of Instance as regular `` `Fork `` nodes.
- #4574: Anomaly: Uncaught exception Invalid_argument("splay_arity").
- Do not give a name to anonymous evars anymore. See bug #4547.
- STM: always stock in vio files the first node (state) of a proof
- STM: not delegate proofs that contain Vernac(Module|Require|Import), #4530
- Don't fail fatally if PATH is not set.
-- #4537: Coq 8.5 is slower in typeclass resolution.
+- #4537: |Coq| 8.5 is slower in typeclass resolution.
- #4522: Incorrect "Warning..." on windows.
- #4373: coqdep does not know about .vio files.
- #3826: "Incompatible module types" is uninformative.
@@ -5158,7 +5265,7 @@ Other bugfixes
- #4503: mixing universe polymorphic and monomorphic variables and definitions in sections is unsupported.
- #4519: oops, global shadowed local universe level bindings.
- #4506: Anomaly: File "pretyping/indrec.ml", line 169, characters 14-20: Assertion failed.
-- #4548: Coqide crashes when going back one command
+- #4548: |CoqIDE| crashes when going back one command
Details of changes in 8.5pl2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -5179,8 +5286,8 @@ Other bugfixes
- #4644: a regression in unification.
- #4725: Function (Error: Conversion test raised an anomaly) and Program
(Error: Cannot infer this placeholder of type)
-- #4747: Problem building Coq 8.5pl1 with OCaml 4.03.0: Fatal warnings
-- #4752: CoqIDE crash on files not ended by ".v".
+- #4747: Problem building |Coq| 8.5pl1 with OCaml 4.03.0: Fatal warnings
+- #4752: |CoqIDE| crash on files not ended by ".v".
- #4777: printing inefficiency with implicit arguments
- #4818: "Admitted" fails due to undefined universe anomaly after calling
"destruct"
@@ -5194,7 +5301,7 @@ Other bugfixes
- #4881: synchronizing "Declare Implicit Tactic" with backtrack.
- #4882: anomaly with Declare Implicit Tactic on hole of type with evars
- Fix use of "Declare Implicit Tactic" in refine.
- triggered by CoqIDE
+ triggered by |CoqIDE|
- #4069, #4718: congruence fails when universes are involved.
Universes
@@ -5257,7 +5364,7 @@ Other bugfixes
- #5097: status of evars refined by "clear" in ltac: closed wrt evars.
- #5150: Missing dependency of the test-suite subsystems in prerequisite.
- Fix a bug in error printing of unif constraints
-- #3941: Do not stop propagation of signals when Coq is busy.
+- #3941: Do not stop propagation of signals when |Coq| is busy.
- #4822: Incorrect assertion in cbn.
- #3479 parsing of "{" and "}" when a keyword starts with "{" or "}".
- #5127: Memory corruption with the VM.
@@ -5271,7 +5378,7 @@ Version 8.4
Summary of changes
~~~~~~~~~~~~~~~~~~
-Coq version 8.4 contains the result of three long-term projects: a new
+|Coq| version 8.4 contains the result of three long-term projects: a new
modular library of arithmetic by Pierre Letouzey, a new proof engine by
Arnaud Spiwack and a new communication protocol for |CoqIDE| by Vincent
Gross.
@@ -5304,7 +5411,7 @@ sessions in parallel. Relying on the infrastructure work made by Vincent
Gross, Pierre Letouzey, Pierre Boutillier and Pierre-Marie Pédrot
contributed many various refinements of |CoqIDE|.
-Coq 8.4 also comes with a bunch of various smaller-scale changes
+|Coq| 8.4 also comes with a bunch of various smaller-scale changes
and improvements regarding the different components of the system.
The underlying logic has been extended with :math:`\eta`-conversion
@@ -5382,14 +5489,14 @@ Julien Forest maintained the Function command.
Matthieu Sozeau maintained the setoid rewriting mechanism.
-Coq related tools have been upgraded too. In particular, coq\_makefile
+|Coq| related tools have been upgraded too. In particular, coq\_makefile
has been largely revised by Pierre Boutillier. Also, patches from Adam
Chlipala for coqdoc have been integrated by Pierre Boutillier.
Bruno Barras and Pierre Letouzey maintained the `coqchk` checker.
Pierre Courtieu and Arnaud Spiwack contributed new features for using
-Coq through Proof General.
+|Coq| through Proof General.
The Dp plugin has been removed. Use the plugin provided with Why 3
instead (http://why3.lri.fr/).
@@ -5641,7 +5748,7 @@ Libraries
* "<?" "<=?" "=?" for boolean tests such as Z.ltb Z.leb Z.eqb.
* "÷" for the alternative integer division Z.quot implementing the Truncate
- convention (former ZOdiv), while the notation for the Coq usual division
+ convention (former ZOdiv), while the notation for the |Coq| usual division
Z.div implementing the Flooring convention remains "/". Their corresponding
modulo functions are Z.rem (no notations) for Z.quot and Z.modulo (infix
"mod" notation) for Z.div.
@@ -5701,31 +5808,31 @@ Extraction
universe polymorphism it cannot handle yet (the pair (I,I) being Prop).
- Support of anonymous fields in record (#2555).
-CoqIDE
+|CoqIDE|
-- Coqide now runs coqtop as separated process, making it more robust:
+- |CoqIDE| now runs coqtop as separated process, making it more robust:
coqtop subprocess can be interrupted, or even killed and relaunched
(cf button "Restart Coq", ex-"Go to Start"). For allowing such
interrupts, the Windows version of coqide now requires Windows >= XP
SP1.
-- The communication between CoqIDE and Coqtop is now done via a dialect
+- The communication between |CoqIDE| and coqtop is now done via a dialect
of XML (DOC TODO).
-- The backtrack engine of CoqIDE has been reworked, it now uses the
+- The backtrack engine of |CoqIDE| has been reworked, it now uses the
"Backtrack" command similarly to Proof General.
-- The Coqide parsing of sentences has be reworked and now supports
+- The |CoqIDE| parsing of sentences has be reworked and now supports
tactic delimitation via { }.
-- Coqide now accepts the Abort command (wish #2357).
-- Coqide can read coq_makefile files as "project file" and use it to
+- |CoqIDE| now accepts the Abort command (wish #2357).
+- |CoqIDE| can read coq_makefile files as "project file" and use it to
set automatically options to send to coqtop.
- Preference files have moved to $XDG_CONFIG_HOME/coq and accelerators
are not stored as a list anymore.
Tools
-- Coq now searches directories specified in COQPATH, $XDG_DATA_HOME/coq,
+- |Coq| now searches directories specified in COQPATH, $XDG_DATA_HOME/coq,
$XDG_DATA_DIRS/coq, and user-contribs before the standard library.
-- Coq rc file has moved to $XDG_CONFIG_HOME/coq.
+- |Coq| rc file has moved to $XDG_CONFIG_HOME/coq.
- Major changes to coq_makefile:
@@ -5783,9 +5890,9 @@ Module System
namespace from ordinary definitions: "Definition E:=0. Module E. End E."
is now accepted.
-CoqIDE
+|CoqIDE|
-- Coqide now supports the "Restart" command, and "Undo" (with a warning).
+- |CoqIDE| now supports the "Restart" command, and "Undo" (with a warning).
Better support for "Abort".
Details of changes in 8.4
@@ -5802,9 +5909,9 @@ Vernacular commands
Notations
- Most compatibility notations of the standard library are now tagged as
- (compat xyz), where xyz is a former Coq version, for instance "8.3".
+ (compat xyz), where xyz is a former |Coq| version, for instance "8.3".
These notations behave as (only parsing) notations, except that they may
- triggers warnings (or errors) when used while Coq is not in a corresponding
+ triggers warnings (or errors) when used while |Coq| is not in a corresponding
-compat mode.
- To activate these compatibility warnings, use "Set Verbose Compat Notations"
or the command-line flag -verbose-compat-notations.
@@ -5834,7 +5941,7 @@ Version 8.3
Summary of changes
~~~~~~~~~~~~~~~~~~
-Coq version 8.3 is before all a transition version with refinements or
+|Coq| version 8.3 is before all a transition version with refinements or
extensions of the existing features and libraries and a new tactic nsatz
based on Hilbert’s Nullstellensatz for deciding systems of equations
over rings.
@@ -5873,7 +5980,7 @@ been done by Matthieu Sozeau, Hugo Herbelin and Pierre Letouzey.
Matthieu Sozeau extended and refined the typeclasses and Program
features (the Russell language). Pierre Letouzey maintained and improved
the extraction mechanism. Bruno Barras and Élie Soubiran maintained the
-Coq checker, Julien Forest maintained the Function mechanism for
+|Coq| checker, Julien Forest maintained the Function mechanism for
reasoning over recursively defined functions. Matthieu Sozeau, Hugo
Herbelin and Jean-Marc Notin maintained coqdoc. Frédéric Besson
maintained the Micromega platform for deciding systems of inequalities.
@@ -6037,12 +6144,12 @@ Module system
"Inline" annotation in the type of its argument(s) (for examples of
use of the new features, see libraries Structures and Numbers).
- Coercions are now active only when modules are imported (use "Set Automatic
- Coercions Import" to get the behavior of the previous versions of Coq).
+ Coercions Import" to get the behavior of the previous versions of |Coq|).
Extraction
- When using (Recursive) Extraction Library, the filenames are directly the
- Coq ones with new appropriate extensions : we do not force anymore
+ |Coq| ones with new appropriate extensions : we do not force anymore
uncapital first letters for Ocaml and capital ones for Haskell.
- The extraction now tries harder to avoid code transformations that can be
dangerous for the complexity. In particular many eta-expansions at the top
@@ -6125,7 +6232,7 @@ Vernacular commands
Library
-- Use "standard" Coq names for the properties of eq and identity
+- Use "standard" |Coq| names for the properties of eq and identity
(e.g. refl_equal is now eq_refl). Support for compatibility is provided.
- The function Compare_dec.nat_compare is now defined directly,
@@ -6176,7 +6283,7 @@ Library
- MSets library: an important evolution of the FSets library.
"MSets" stands for Modular (Finite) Sets, by contrast with a forthcoming
library of Class (Finite) Sets contributed by S. Lescuyer which will be
- integrated with the next release of Coq. The main features of MSets are:
+ integrated with the next release of |Coq|. The main features of MSets are:
+ The use of Equivalence, Proper and other Type Classes features
easing the handling of setoid equalities.
@@ -6191,7 +6298,7 @@ Library
Note: No Maps yet in MSets. The FSets library is still provided
for compatibility, but will probably be considered as deprecated in the
- next release of Coq.
+ next release of |Coq|.
- Numbers library:
@@ -6207,12 +6314,12 @@ Library
Tools
-- Option -R now supports binding Coq root read-only.
+- Option -R now supports binding |Coq| root read-only.
- New coqtop/coqc option -beautify to reformat .v files (usable
e.g. to globally update notations).
- New tool beautify-archive to beautify a full archive of developments.
- New coqtop/coqc option -compat X.Y to simulate the general behavior
- of previous versions of Coq (provides e.g. support for 8.2 compatibility).
+ of previous versions of |Coq| (provides e.g. support for 8.2 compatibility).
Coqdoc
@@ -6228,7 +6335,7 @@ Coqdoc
- New option "--parse-comments" to allow parsing of regular ``(* *)``
comments.
- New option "--plain-comments" to disable interpretation inside comments.
-- New option "--interpolate" to try and typeset identifiers in Coq escapings
+- New option "--interpolate" to try and typeset identifiers in |Coq| escapings
using the available globalization information.
- New option "--external url root" to refer to external libraries.
- Links to section variables and notations now supported.
@@ -6242,7 +6349,7 @@ Internal infrastructure
- An experimental build mechanism via ocamlbuild is provided.
From the top of the archive, run ./configure as usual, and
then ./build. Feedback about this build mechanism is most welcome.
- Compiling Coq on platforms such as Windows might be simpler
+ Compiling |Coq| on platforms such as Windows might be simpler
this way, but this remains to be tested.
- The Makefile system has been simplified and factorized with
the ocamlbuild system. In particular "make" takes advantage
@@ -6255,7 +6362,7 @@ Version 8.2
Summary of changes
~~~~~~~~~~~~~~~~~~
-Coq version 8.2 adds new features, new libraries and improves on many
+|Coq| version 8.2 adds new features, new libraries and improves on many
various aspects.
Regarding the language of |Coq|, the main novelty is the introduction by
@@ -6410,7 +6517,7 @@ Vernacular commands
qualified names (this holds also for coqtop/coqc option -R).
- SearchAbout supports negated search criteria, reference to logical objects
by their notation, and more generally search of subterms.
-- "Declare ML Module" now allows to import .cmxs files when Coq is
+- "Declare ML Module" now allows to import .cmxs files when |Coq| is
compiled in native code with a version of OCaml that supports native
Dynlink (>= 3.11).
- Specific sort constraints on Record now taken into account.
@@ -6451,7 +6558,7 @@ Libraries
version should be fairly good, but some adaptations may be required.
* Interfaces of unordered ("weak") and ordered sets have been factorized
- thanks to new features of Coq modules (in particular Include), see
+ thanks to new features of |Coq| modules (in particular Include), see
FSetInterface. Same for maps. Hints in these interfaces have been
reworked (they are now placed in a "set" database).
* To allow full subtyping between weak and ordered sets, a field
@@ -6482,7 +6589,7 @@ Libraries
initial Ocaml code and written via the Function framework.
- Library IntMap, subsumed by FSets/FMaps, has been removed from
- Coq Standard Library and moved into a user contribution Cachan/IntMap
+ |Coq| Standard Library and moved into a user contribution Cachan/IntMap
- Better computational behavior of some constants (eq_nat_dec and
le_lt_dec more efficient, Z_lt_le_dec and Positive_as_OT.compare
@@ -6687,7 +6794,7 @@ Tactics
- New tactic "specialize H with a" or "specialize (H a)" allows to transform
in-place a universally-quantified hypothesis (H : forall x, T x) into its
instantiated form (H : T a). Nota: "specialize" was in fact there in earlier
- versions of Coq, but was undocumented, and had a slightly different behavior.
+ versions of |Coq|, but was undocumented, and had a slightly different behavior.
- New tactic "contradict H" can be used to solve any kind of goal as long as
the user can provide afterwards a proof of the negation of the hypothesis H.
@@ -6731,7 +6838,7 @@ Program
- Program Lemma, Axiom etc... now permit to have obligations in the statement
iff they can be automatically solved by the default tactic.
- Renamed "Obligations Tactic" command to "Obligation Tactic".
-- New command "Preterm [ of id ]" to see the actual term fed to Coq for
+- New command "Preterm [ of id ]" to see the actual term fed to |Coq| for
debugging purposes.
- New option "Transparent Obligations" to control the declaration of
obligations as transparent or opaque. All obligations are now transparent
@@ -6823,7 +6930,7 @@ Extraction
not happen anymore.
- The command Extract Inductive has now a syntax for infix notations. This
- allows in particular to map Coq lists and pairs onto Caml ones:
+ allows in particular to map |Coq| lists and pairs onto |OCaml| ones:
+ Extract Inductive list => list [ "[]" "(::)" ].
+ Extract Inductive prod => "(*)" [ "(,)" ].
@@ -6837,16 +6944,16 @@ Extraction
conflits with existing code, for instance when extracting module List
to Ocaml.
-CoqIDE
+|CoqIDE|
-- CoqIDE font defaults to monospace so as indentation to be meaningful.
-- CoqIDE supports nested goals and any other kind of declaration in the middle
+- |CoqIDE| font defaults to monospace so as indentation to be meaningful.
+- |CoqIDE| supports nested goals and any other kind of declaration in the middle
of a proof.
-- Undoing non-tactic commands in CoqIDE works faster.
-- New CoqIDE menu for activating display of various implicit informations.
+- Undoing non-tactic commands in |CoqIDE| works faster.
+- New |CoqIDE| menu for activating display of various implicit informations.
- Added the possibility to choose the location of tabs in coqide:
(in Edit->Preferences->Misc)
-- New Open and Save As dialogs in CoqIDE which filter ``*.v`` files.
+- New Open and Save As dialogs in |CoqIDE| which filter ``*.v`` files.
Tools
@@ -6855,22 +6962,22 @@ Tools
- New coqtop/coqc option -exclude-dir to exclude subdirs for option -R.
- The binary "parser" has been renamed to "coq-parser".
- Improved coqdoc and dump of globalization information to give more
- meta-information on identifiers. All categories of Coq definitions are
+ meta-information on identifiers. All categories of |Coq| definitions are
supported, which makes typesetting trivial in the generated documentation.
Support for hyperlinking and indexing developments in the tex output
has been implemented as well.
Miscellaneous
-- Coq installation provides enough files so that Ocaml's extensions need not
- the Coq sources to be compiled (this assumes O'Caml 3.10 and Camlp5).
+- |Coq| installation provides enough files so that Ocaml's extensions need not
+ the |Coq| sources to be compiled (this assumes O'Caml 3.10 and Camlp5).
- New commands "Set Whelp Server" and "Set Whelp Getter" to customize the
Whelp search tool.
- Syntax of "Test Printing Let ref" and "Test Printing If ref" changed into
"Test Printing Let for ref" and "Test Printing If for ref".
- An overhauled build system (new Makefiles); see dev/doc/build-system.txt.
- Add -browser option to configure script.
-- Build a shared library for the C part of Coq, and use it by default on
+- Build a shared library for the C part of |Coq|, and use it by default on
non-(Windows or MacOS) systems. Bytecode executables are now pure. The
behaviour is configurable with -coqrunbyteflags, -coqtoolsbyteflags and
-custom configure options.
@@ -6883,7 +6990,7 @@ Version 8.1
Summary of changes
~~~~~~~~~~~~~~~~~~
-Coq version 8.1 adds various new functionalities.
+|Coq| version 8.1 adds various new functionalities.
Benjamin Grégoire implemented an alternative algorithm to check the
convertibility of terms in the |Coq| type checker. This alternative
@@ -6991,7 +7098,7 @@ Vernacular commands
Ltac and tactic syntactic extensions
-- New primitive "external" for communication with tool external to Coq
+- New primitive "external" for communication with tool external to |Coq|
- New semantics for "match t with": if a clause returns a
tactic, it is now applied to the current goal. If it fails, the next
clause or next matching subterm is tried (i.e. it behaves as "match
@@ -7016,7 +7123,7 @@ Tactics
- New conversion tactic "vm_compute": evaluates the goal (or an hypothesis)
with a call-by-value strategy, using the compiled version of terms.
-- When rewriting H where H is not directly a Coq equality, search first H for
+- When rewriting H where H is not directly a |Coq| equality, search first H for
a registered setoid equality before starting to reduce in H. This is unlikely
to break any script. Should this happen nonetheless, one can insert manually
some "unfold ... in H" before rewriting.
@@ -7061,7 +7168,7 @@ Tactics
- New tactic "pose proof" that generalizes "assert (id:=p)" with intro patterns.
-- New introduction pattern "?" for letting Coq choose a name.
+- New introduction pattern "?" for letting |Coq| choose a name.
- Introduction patterns now support side hypotheses (e.g. intros [|] on
"(nat -> nat) -> nat" works).
@@ -7147,7 +7254,7 @@ Libraries
Zlt_square_simpl removed; fixed names mentioning letter O instead of
digit 0; weaken premises in Z_lt_induction).
- Restructuration of Eqdep_dec.v and Eqdep.v: more lemmas in Type.
-- Znumtheory now contains a gcd function that can compute within Coq.
+- Znumtheory now contains a gcd function that can compute within |Coq|.
- More lemmas stated on Type in Wf.v, removal of redundant Acc_iter and
Acc_iter2.
- Change of the internal names of lemmas in OmegaLemmas.
@@ -7180,7 +7287,7 @@ Tools
- Tool coq_makefile now removes custom targets that are file names in
"make clean"
- New environment variable COQREMOTEBROWSER to set the command invoked
- to start the remote browser both in Coq and coqide. Standard syntax:
+ to start the remote browser both in |Coq| and |CoqIDE|. Standard syntax:
"%s" is the placeholder for the URL.
Details of changes in 8.1gamma
@@ -7256,7 +7363,7 @@ Version 8.0
Summary of changes
~~~~~~~~~~~~~~~~~~
-Coq version 8 is a major revision of the |Coq| proof assistant. First, the
+|Coq| version 8 is a major revision of the |Coq| proof assistant. First, the
underlying logic is slightly different. The so-called *impredicativity*
of the sort Set has been dropped. The main reason is that it is
inconsistent with the principle of description which is quite a useful
@@ -7294,7 +7401,7 @@ purpose here is a better uniformity making the tactics and commands
easier to use and to remember.
Thirdly, a restructuring and uniformization of the standard library of
-Coq has been performed. There is now just one Leibniz equality usable
+|Coq| has been performed. There is now just one Leibniz equality usable
for all the different kinds of |Coq| objects. Also, the set of real
numbers now lies at the same level as the sets of natural and integer
numbers. Finally, the names of the standard properties of numbers now
@@ -7511,19 +7618,19 @@ Miscellaneous
Incompatibilities
-- Persistence of true_sub (4 incompatibilities in Coq user contributions)
+- Persistence of true_sub (4 incompatibilities in |Coq| user contributions)
- Variable names of some constants changed for a better uniformity (2 changes
- in Coq user contributions)
+ in |Coq| user contributions)
- Naming of quantified names in goal now avoid global names (2 occurrences)
- NewInduction naming for inductive types with functional arguments
- (no incompatibility in Coq user contributions)
+ (no incompatibility in |Coq| user contributions)
- Contradiction now solve more goals (source of 2 incompatibilities)
- Merge of eq and eqT may exceptionally result in subgoals now
solved automatically
- Redundant pairs of ZArith lemmas may have different names: it may
cause "Apply/Rewrite with" to fail if using the first name of a pair
of redundant lemmas (this is solved by renaming the variables bound by
- "with"; 3 incompatibilities in Coq user contribs)
+ "with"; 3 incompatibilities in |Coq| user contribs)
- ML programs referring to constants from fast_integer.v must use
"Coqlib.gen_constant_modules Coqlib.zarith_base_modules" instead
@@ -7559,7 +7666,7 @@ Revision of the standard library
"Zmult_le_compat_r", "SUPERIEUR" -> "Gt", "ZERO" -> "Z0")
- Order and names of arguments of basic lemmas on nat, Z, positive and R
have been made uniform.
-- Notions of Coq initial state are declared with (strict) implicit arguments
+- Notions of |Coq| initial state are declared with (strict) implicit arguments
- eq merged with eqT: old eq disappear, new eq (written =) is old eqT
and new eqT is syntactic sugar for new eq (notation == is an alias
for = and is written as it, exceptional source of incompatibilities)
@@ -7590,7 +7697,7 @@ Known problems of the automatic translation
- iso-latin-1 characters are no longer supported: move your files to
7-bits ASCII or unicode before translation (switch to unicode is
automatically done if a file is loaded and saved again by coqide)
-- Renaming in ZArith: incompatibilities in Coq user contribs due to
+- Renaming in ZArith: incompatibilities in |Coq| user contribs due to
merging names INZ, from Reals, and inject_nat.
- Renaming and new lemmas in ZArith: may clash with names used by users
- Restructuration of ZArith: replace requirement of specific modules
@@ -7640,7 +7747,7 @@ Tactics and the tactic Language
Executables and tools
- Added option -top to change the name of the toplevel module "Top"
-- Coqdoc updated to new syntax and now part of Coq sources
+- Coqdoc updated to new syntax and now part of |Coq| sources
- XML exportation tool now exports the structure of vernacular files
(cf chapter 13 in the reference manual)
diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py
index a8a574c861..75ac2a76cd 100755
--- a/doc/sphinx/conf.py
+++ b/doc/sphinx/conf.py
@@ -183,9 +183,7 @@ todo_include_todos = False
nitpicky = True
nitpick_ignore = [ ('token', token) for token in [
- 'collection',
'tactic',
- 'bindings',
'induction_clause',
'conversion',
'where',
diff --git a/doc/sphinx/history.rst b/doc/sphinx/history.rst
index 02821613cc..bab9bfcadb 100644
--- a/doc/sphinx/history.rst
+++ b/doc/sphinx/history.rst
@@ -1,16 +1,16 @@
.. _history:
---------------------
-Early history of Coq
---------------------
+----------------------
+Early history of |Coq|
+----------------------
Historical roots
----------------
-Coq is a proof assistant for higher-order logic, allowing the
+|Coq| is a proof assistant for higher-order logic, allowing the
development of computer programs consistent with their formal
specification. It is the result of about ten years [#years]_ of research
-of the Coq project. We shall briefly survey here three main aspects: the
+of the |Coq| project. We shall briefly survey here three main aspects: the
*logical language* in which we write our axiomatizations and
specifications, the *proof assistant* which allows the development of
verified mathematical proofs, and the *program extractor* which
@@ -153,7 +153,7 @@ by A. Felty. It allowed operation of the theorem-prover through the
manipulation of windows, menus, mouse-sensitive buttons, and other
widgets. This system (Version 5.6) was released in 1991.
-Coq was ported to the new implementation Caml-light of X. Leroy and D.
+|Coq| was ported to the new implementation Caml-light of X. Leroy and D.
Doligez by D. de Rauglaudre (Version 5.7) in 1992. A new version of |Coq|
was then coordinated by C. Murthy, with new tools designed by C. Parent
to prove properties of ML programs (this methodology is dual to program
@@ -477,7 +477,7 @@ C. Paulin-Mohring. *Inductively defined types* :cite:`CP90`.
This led to the Calculus of Inductive Constructions, logical formalism
implemented in Versions 5 upward of the system, and documented in:
-C. Paulin-Mohring. *Inductive Definitions in the System Coq - Rules
+C. Paulin-Mohring. *Inductive Definitions in the System |Coq| - Rules
and Properties* :cite:`P93`.
The last version of CONSTR is Version 4.11, which was last distributed
@@ -489,7 +489,7 @@ Version 5
~~~~~~~~~
At the end of 1989, Version 5.1 was started, and renamed as the system
-Coq for the Calculus of Inductive Constructions. It was then ported to
+|Coq| for the Calculus of Inductive Constructions. It was then ported to
the new stand-alone implementation of ML called Caml-light.
In 1990 many changes occurred. Thierry Coquand left for Chalmers
@@ -497,7 +497,7 @@ University in Göteborg. Christine Paulin-Mohring took a CNRS
researcher position at the LIP laboratory of École Normale Supérieure
de Lyon. Project Formel was terminated, and gave rise to two teams:
Cristal at INRIA-Roquencourt, that continued developments in
-functional programming with Caml-light then OCaml, and Coq, continuing
+functional programming with Caml-light then OCaml, and |Coq|, continuing
the type theory research, with a joint team headed by Gérard Huet at
INRIA-Rocquencourt and Christine Paulin-Mohring at the LIP laboratory
of CNRS-ENS Lyon.
@@ -736,7 +736,7 @@ Notes:
Main novelties
^^^^^^^^^^^^^^
-References are to Coq 7.1 reference manual
+References are to |Coq| 7.1 reference manual
- New primitive let-in construct (see sections 1.2.8 and )
- Long names (see sections 2.6 and 2.7)
@@ -770,7 +770,7 @@ Language: long names
name, the name of the module in which they are defined (Top if in
coqtop), and possibly an arbitrary long sequence of directory (e.g.
"Coq.Lists.PolyList.flat_map" where "Coq" means that "flat_map" is part
- of Coq standard library, "Lists" means it is defined in the Lists
+ of |Coq| standard library, "Lists" means it is defined in the Lists
library and "PolyList" means it is in the file Polylist) (+)
- Constructions can be referred by their base name, or, in case of
@@ -829,7 +829,7 @@ Reduction
- Constants declared as opaque (using Qed) can no longer become
transparent (a constant intended to be alternatively opaque and
transparent must be declared as transparent (using Defined)); a risk
- exists (until next Coq version) that Simpl and Hnf reduces opaque
+ exists (until next |Coq| version) that Simpl and Hnf reduces opaque
constants (*)
@@ -1171,7 +1171,7 @@ Incompatibilities
- New naming strategy for NewInduction/NewDestruct may affect 7.1 compatibility
- Extra parentheses may exceptionally be needed in tactic definitions.
-- Coq extensions written in Ocaml need to be updated (see dev/changements.txt
+- |Coq| extensions written in |OCaml| need to be updated (see dev/changements.txt
for a description of the main changes in the interface files of V7.2)
- New behaviour of Intuition/Tauto may exceptionally lead to incompatibilities
@@ -1205,7 +1205,7 @@ Tactics
product if needed (source of incompatibilities)
- "Match Context" now matching more recent hypotheses first and failing only
on user errors and Fail tactic (possible source of incompatibilities)
-- Tactic Definition's without arguments now allowed in Coq states
+- Tactic Definition's without arguments now allowed in |Coq| states
- Better simplification and discrimination made by Inversion (source
of incompatibilities)
@@ -1239,7 +1239,7 @@ User Contributions
- CongruenceClosure (congruence closure decision procedure)
[Pierre Corbineau, ENS Cachan]
- MapleMode (an interface to embed Maple simplification procedures over
- rational fractions in Coq)
+ rational fractions in |Coq|)
[David Delahaye, Micaela Mayero, Chalmers University]
- Presburger: A formalization of Presburger's algorithm
[Laurent Thery, INRIA Sophia Antipolis]
@@ -1283,7 +1283,7 @@ Bug fixes
Misc
- - Ocaml version >= 3.06 is needed to compile Coq from sources
+ - Ocaml version >= 3.06 is needed to compile |Coq| from sources
- Simplification of fresh names creation strategy for Assert, Pose and
LetTac (#1402)
@@ -1398,7 +1398,7 @@ Extraction (See details in plugins/extraction/CHANGES and README):
- An experimental Scheme extraction is provided.
- Concerning OCaml, extracted code is now ensured to always type check,
thanks to automatic inserting of Obj.magic.
-- Experimental extraction of Coq new modules to Ocaml modules.
+- Experimental extraction of |Coq| new modules to Ocaml modules.
Proof rendering in natural language
diff --git a/doc/sphinx/introduction.rst b/doc/sphinx/introduction.rst
index b059fb4069..dc16897d42 100644
--- a/doc/sphinx/introduction.rst
+++ b/doc/sphinx/introduction.rst
@@ -1,8 +1,8 @@
-This is the reference manual of |Coq|. Coq is an interactive theorem
+This is the reference manual of |Coq|. |Coq| is an interactive theorem
prover. It lets you formalize mathematical concepts and then helps
you interactively generate machine-checked proofs of theorems.
Machine checking gives users much more confidence that the proofs are
-correct compared to human-generated and -checked proofs. Coq has been
+correct compared to human-generated and -checked proofs. |Coq| has been
used in a number of flagship verification projects, including the
`CompCert verified C compiler <http://compcert.inria.fr/>`_, and has
served to verify the proof of the `four color theorem
@@ -18,49 +18,49 @@ arithmetic). :ref:`Ltac <ltac>` and its planned replacement,
combining existing tactics with looping and conditional constructs.
These permit automation of large parts of proofs and sometimes entire
proofs. Furthermore, users can add novel tactics or functionality by
-creating Coq plugins using OCaml.
+creating |Coq| plugins using |OCaml|.
-The Coq kernel, a small part of Coq, does the final verification that
+The |Coq| kernel, a small part of |Coq|, does the final verification that
the tactic-generated proof is valid. Usually the tactic-generated
proof is indeed correct, but delegating proof verification to the
kernel means that even if a tactic is buggy, it won't be able to
introduce an incorrect proof into the system.
-Finally, Coq also supports extraction of verified programs to
-programming languages such as OCaml and Haskell. This provides a way
-of executing Coq code efficiently and can be used to create verified
+Finally, |Coq| also supports extraction of verified programs to
+programming languages such as |OCaml| and Haskell. This provides a way
+of executing |Coq| code efficiently and can be used to create verified
software libraries.
-To learn Coq, beginners are advised to first start with a tutorial /
+To learn |Coq|, beginners are advised to first start with a tutorial /
book. Several such tutorials / books are listed at
https://coq.inria.fr/documentation.
This manual is organized in three main parts, plus an appendix:
-- **The first part presents the specification language of Coq**, that
+- **The first part presents the specification language of |Coq|**, that
allows to define programs and state mathematical theorems.
- :ref:`core-language` presents the language that the kernel of Coq
+ :ref:`core-language` presents the language that the kernel of |Coq|
understands. :ref:`extensions` presents the richer language, with
notations, implicits, etc. that a user can use and which is
translated down to the language of the kernel by means of an
"elaboration process".
- **The second part presents the interactive proof mode**, the central
- feature of Coq. :ref:`writing-proofs` introduces this interactive
+ feature of |Coq|. :ref:`writing-proofs` introduces this interactive
proof mode and the available proof languages.
:ref:`automatic-tactics` presents some more advanced tactics, while
:ref:`writing-tactics` is about the languages that allow a user to
combine tactics together and develop new ones.
-- **The third part shows how to use Coq in practice.**
+- **The third part shows how to use |Coq| in practice.**
:ref:`libraries` presents some of the essential reusable blocks from
the ecosystem and some particularly important extensions such as the
program extraction mechanism. :ref:`tools` documents important
- tools that a user needs to build a Coq project.
+ tools that a user needs to build a |Coq| project.
- In the appendix, :ref:`history-and-changes` presents the history of
- Coq and changes in recent releases. This is an important reference
- if you upgrade the version of Coq that you use. The various
+ |Coq| and changes in recent releases. This is an important reference
+ if you upgrade the version of |Coq| that you use. The various
:ref:`indexes <indexes>` are very useful to **quickly browse the
manual and find what you are looking for.** They are often the main
entry point to the manual.
diff --git a/doc/sphinx/language/core/assumptions.rst b/doc/sphinx/language/core/assumptions.rst
index 41e1c30f0d..a38282d41a 100644
--- a/doc/sphinx/language/core/assumptions.rst
+++ b/doc/sphinx/language/core/assumptions.rst
@@ -117,7 +117,7 @@ Assumptions
Assumptions extend the environment with axioms, parameters, hypotheses
or variables. An assumption binds an :n:`@ident` to a :n:`@type`. It is accepted
-by Coq if and only if this :n:`@type` is a correct type in the environment
+by |Coq| if and only if this :n:`@type` is a correct type in the environment
preexisting the declaration and if :n:`@ident` was not previously defined in
the same module. This :n:`@type` is considered to be the type (or
specification, or statement) assumed by :n:`@ident` and we say that :n:`@ident`
@@ -141,8 +141,8 @@ has type :n:`@type`.
of_type ::= {| : | :> } @type
These commands bind one or more :n:`@ident`\(s) to specified :n:`@type`\(s) as their specifications in
- the global context. The fact asserted by the :n:`@type` (or, equivalently, the existence
- of an object of this type) is accepted as a postulate.
+ the global context. The fact asserted by :n:`@type` (or, equivalently, the existence
+ of an object of this type) is accepted as a postulate. They accept the :attr:`program` attribute.
:cmd:`Axiom`, :cmd:`Conjecture`, :cmd:`Parameter` and their plural forms
are equivalent. They can take the :attr:`local` :term:`attribute`,
@@ -155,6 +155,10 @@ has type :n:`@type`.
is closed, the :n:`@ident`\(s) become undefined and every object depending on them will be explicitly
parameterized (i.e., the variables are *discharged*). See Section :ref:`section-mechanism`.
+ :n:`:>`
+ If specified, :token:`ident_decl` is automatically
+ declared as a coercion to the class of its type. See :ref:`coercions`.
+
The :n:`Inline` clause is only relevant inside functors. See :cmd:`Module`.
.. example:: Simple assumptions
diff --git a/doc/sphinx/language/core/basic.rst b/doc/sphinx/language/core/basic.rst
index 45bdc019ac..dfa2aaf8ff 100644
--- a/doc/sphinx/language/core/basic.rst
+++ b/doc/sphinx/language/core/basic.rst
@@ -113,7 +113,7 @@ Identifiers
Numbers
Numbers are sequences of digits with an optional fractional part
- and exponent, optionally preceded by a minus sign. Hexadecimal numerals
+ and exponent, optionally preceded by a minus sign. Hexadecimal numbers
start with ``0x`` or ``0X``. :n:`@bigint` are integers;
numbers without fractional nor exponent parts. :n:`@bignat` are non-negative
integers. Underscores embedded in the digits are ignored, for example
@@ -134,7 +134,7 @@ Numbers
hexdigit ::= {| 0 .. 9 | a .. f | A .. F }
:n:`@integer` and :n:`@natural` are limited to the range that fits
- into an OCaml integer (63-bit integers on most architectures).
+ into an |OCaml| integer (63-bit integers on most architectures).
:n:`@bigint` and :n:`@bignat` have no range limitation.
The :ref:`standard library <thecoqlibrary>` provides some
@@ -152,8 +152,8 @@ Strings
:token:`string`.
Keywords
- The following character sequences are keywords defined in the main Coq grammar
- that cannot be used as identifiers (even when starting Coq with the `-noinit`
+ The following character sequences are keywords defined in the main |Coq| grammar
+ that cannot be used as identifiers (even when starting |Coq| with the `-noinit`
command-line flag)::
_ Axiom CoFixpoint Definition Fixpoint Hypothesis Parameter Prop
@@ -168,11 +168,11 @@ Keywords
keywords.
Other tokens
- The following character sequences are tokens defined in the main Coq grammar
- (even when starting Coq with the `-noinit` command-line flag)::
+ The following character sequences are tokens defined in the main |Coq| grammar
+ (even when starting |Coq| with the `-noinit` command-line flag)::
! #[ % & ' ( () ) * + , - ->
- . .( .. ... / : ::= := :> :>> ; < <+ <- <:
+ . .( .. ... / : ::= := :> ; < <+ <- <:
<<: <= = => > >-> >= ? @ @{ [ ] _
`( `{ { {| | }
@@ -325,10 +325,10 @@ rest of the |Coq| manual: :term:`terms <term>` and :term:`types
boldface label "Command:". Commands are listed in the
:ref:`command_index`. Example:
- .. cmd:: Comments {* @string }
+ .. cmd:: Comments {* {| @one_term | @string | @natural } }
- This command prints "Comments ok" and does not change anything
- to the state of the document.
+ Prints "Comments ok" and does not change
+ the state of the document.
tactic
diff --git a/doc/sphinx/language/core/coinductive.rst b/doc/sphinx/language/core/coinductive.rst
index c034b7f302..2e5dff42ac 100644
--- a/doc/sphinx/language/core/coinductive.rst
+++ b/doc/sphinx/language/core/coinductive.rst
@@ -28,8 +28,8 @@ More information on co-inductive definitions can be found in
This command supports the :attr:`universes(polymorphic)`,
:attr:`universes(monomorphic)`, :attr:`universes(template)`,
:attr:`universes(notemplate)`, :attr:`universes(cumulative)`,
- :attr:`universes(noncumulative)` and :attr:`private(matching)`
- attributes.
+ :attr:`universes(noncumulative)`, :attr:`private(matching)`
+ and :attr:`using` attributes.
.. example::
@@ -76,7 +76,7 @@ propositional η-equality, which itself would require full η-conversion for
subject reduction to hold, but full η-conversion is not acceptable as it would
make type checking undecidable.
-Since the introduction of primitive records in Coq 8.5, an alternative
+Since the introduction of primitive records in |Coq| 8.5, an alternative
presentation is available, called *negative co-inductive types*. This consists
in defining a co-inductive type as a primitive record type through its
projections. Such a technique is akin to the *co-pattern* style that can be
@@ -115,7 +115,7 @@ equality:
Axiom Stream_ext : forall (s1 s2: Stream), EqSt s1 s2 -> s1 = s2.
-As of Coq 8.9, it is now advised to use negative co-inductive types rather than
+As of |Coq| 8.9, it is now advised to use negative co-inductive types rather than
their positive counterparts.
.. seealso::
@@ -195,7 +195,7 @@ Top-level definitions of co-recursive functions
As in the :cmd:`Fixpoint` command, the :n:`with` clause allows simultaneously
defining several mutual cofixpoints.
- If :n:`@term` is omitted, :n:`@type` is required and Coq enters proof editing mode.
+ If :n:`@term` is omitted, :n:`@type` is required and |Coq| enters proof editing mode.
This can be used to define a term incrementally, in particular by relying on the :tacn:`refine` tactic.
In this case, the proof should be terminated with :cmd:`Defined` in order to define a constant
for which the computational behavior is relevant. See :ref:`proof-editing-mode`.
diff --git a/doc/sphinx/language/core/definitions.rst b/doc/sphinx/language/core/definitions.rst
index 42203d9d65..1681eee6e7 100644
--- a/doc/sphinx/language/core/definitions.rst
+++ b/doc/sphinx/language/core/definitions.rst
@@ -87,10 +87,10 @@ Section :ref:`typing-rules`.
computation on :n:`@term`.
These commands also support the :attr:`universes(polymorphic)`,
- :attr:`universes(monomorphic)`, :attr:`program` and
- :attr:`canonical` attributes.
+ :attr:`universes(monomorphic)`, :attr:`program` (see :ref:`program_definition`),
+ :attr:`canonical` and :attr:`using` attributes.
- If :n:`@term` is omitted, :n:`@type` is required and Coq enters proof editing mode.
+ If :n:`@term` is omitted, :n:`@type` is required and |Coq| enters proof editing mode.
This can be used to define a term incrementally, in particular by relying on the :tacn:`refine` tactic.
In this case, the proof should be terminated with :cmd:`Defined` in order to define a constant
for which the computational behavior is relevant. See :ref:`proof-editing-mode`.
@@ -135,11 +135,13 @@ Chapter :ref:`Tactics`. The basic assertion command is:
| Proposition
| Property
- After the statement is asserted, Coq needs a proof. Once a proof of
+ After the statement is asserted, |Coq| needs a proof. Once a proof of
:n:`@type` under the assumptions represented by :n:`@binder`\s is given and
validated, the proof is generalized into a proof of :n:`forall {* @binder }, @type` and
the theorem is bound to the name :n:`@ident` in the environment.
+ These commands accept the :attr:`program` attribute. See :ref:`program_lemma`.
+
Forms using the :n:`with` clause are useful for theorems that are proved by simultaneous induction
over a mutually inductive assumption, or that assert mutually dependent
statements in some mutual co-inductive type. It is equivalent to
@@ -157,6 +159,8 @@ Chapter :ref:`Tactics`. The basic assertion command is:
correct at some time of the interactive development of a proof, use the
command :cmd:`Guarded`.
+ This command accepts the :attr:`using` attribute.
+
.. exn:: The term @term has type @type which should be Set, Prop or Type.
:undocumented:
@@ -172,7 +176,7 @@ Chapter :ref:`Tactics`. The basic assertion command is:
This feature, called nested proofs, is disabled by default.
To activate it, turn the :flag:`Nested Proofs Allowed` flag on.
-Proofs start with the keyword :cmd:`Proof`. Then Coq enters the proof editing mode
+Proofs start with the keyword :cmd:`Proof`. Then |Coq| enters the proof editing mode
until the proof is completed. In proof editing mode, the user primarily enters
tactics, which are described in chapter :ref:`Tactics`. The user may also enter
commands to manage the proof editing mode. They are described in Chapter
diff --git a/doc/sphinx/language/core/index.rst b/doc/sphinx/language/core/index.rst
index de780db267..c7b1df28db 100644
--- a/doc/sphinx/language/core/index.rst
+++ b/doc/sphinx/language/core/index.rst
@@ -4,7 +4,7 @@
Core language
=============
-At the heart of the Coq proof assistant is the Coq kernel. While
+At the heart of the |Coq| proof assistant is the |Coq| kernel. While
users have access to a language with many convenient features such as
:ref:`notations <syntax-extensions-and-notation-scopes>`,
:ref:`implicit arguments <ImplicitArguments>`, etc. (presented in the
diff --git a/doc/sphinx/language/core/inductive.rst b/doc/sphinx/language/core/inductive.rst
index 4cdfba146a..1642482bb1 100644
--- a/doc/sphinx/language/core/inductive.rst
+++ b/doc/sphinx/language/core/inductive.rst
@@ -13,11 +13,11 @@ Inductive types
.. prodn::
inductive_definition ::= {? > } @ident_decl {* @binder } {? %| {* @binder } } {? : @type } {? := {? @constructors_or_record } } {? @decl_notations }
constructors_or_record ::= {? %| } {+| @constructor }
- | {? @ident } %{ {*; @record_field } %}
+ | {? @ident } %{ {*; @record_field } {? ; } %}
constructor ::= @ident {* @binder } {? @of_type }
This command defines one or more
- inductive types and its constructors. Coq generates destructors
+ inductive types and its constructors. |Coq| generates destructors
depending on the universe that the inductive type belongs to.
The destructors are named :n:`@ident`\ ``_rect``, :n:`@ident`\ ``_ind``,
@@ -342,9 +342,9 @@ Recursive functions: fix
.. insertprodn term_fix fixannot
.. prodn::
- term_fix ::= let fix @fix_body in @term
- | fix @fix_body {? {+ with @fix_body } for @ident }
- fix_body ::= @ident {* @binder } {? @fixannot } {? : @type } := @term
+ term_fix ::= let fix @fix_decl in @term
+ | fix @fix_decl {? {+ with @fix_decl } for @ident }
+ fix_decl ::= @ident {* @binder } {? @fixannot } {? : @type } := @term
fixannot ::= %{ struct @ident %}
| %{ wf @one_term @ident %}
| %{ measure @one_term {? @ident } {? @one_term } %}
@@ -361,7 +361,11 @@ syntax: :n:`let fix @ident {* @binder } := @term in` stands for
Some options of :n:`@fixannot` are only supported in specific constructs. :n:`fix` and :n:`let fix`
only support the :n:`struct` option, while :n:`wf` and :n:`measure` are only supported in
-commands such as :cmd:`Function` and :cmd:`Program Fixpoint`.
+commands such as :cmd:`Fixpoint` (with the :attr:`program` attribute) and :cmd:`Function`.
+
+.. todo explanation of struct: see text above at the Fixpoint command, also
+ see https://github.com/coq/coq/pull/12936#discussion_r510716268 and above.
+ Consider whether to move the grammar for fixannot elsewhere
.. _Fixpoint:
@@ -379,7 +383,7 @@ constructions.
.. prodn::
fix_definition ::= @ident_decl {* @binder } {? @fixannot } {? : @type } {? := @term } {? @decl_notations }
- This command allows defining functions by pattern matching over inductive
+ Allows defining functions by pattern matching over inductive
objects using a fixed point construction. The meaning of this declaration is
to define :n:`@ident` as a recursive function with arguments specified by
the :n:`@binder`\s such that :n:`@ident` applied to arguments
@@ -388,6 +392,8 @@ constructions.
consequently :n:`forall {* @binder }, @type` and its value is equivalent
to :n:`fun {* @binder } => @term`.
+ This command accepts the :attr:`program` attribute.
+
To be accepted, a :cmd:`Fixpoint` definition has to satisfy syntactical
constraints on a special argument called the decreasing argument. They
are needed to ensure that the :cmd:`Fixpoint` definition always terminates.
@@ -399,17 +405,19 @@ constructions.
that satisfies the decreasing condition.
:cmd:`Fixpoint` without the :attr:`program` attribute does not support the
- :n:`wf` or :n:`measure` clauses of :n:`@fixannot`.
+ :n:`wf` or :n:`measure` clauses of :n:`@fixannot`. See :ref:`program_fixpoint`.
The :n:`with` clause allows simultaneously defining several mutual fixpoints.
It is especially useful when defining functions over mutually defined
inductive types. Example: :ref:`Mutual Fixpoints<example_mutual_fixpoints>`.
- If :n:`@term` is omitted, :n:`@type` is required and Coq enters proof editing mode.
+ If :n:`@term` is omitted, :n:`@type` is required and |Coq| enters proof editing mode.
This can be used to define a term incrementally, in particular by relying on the :tacn:`refine` tactic.
In this case, the proof should be terminated with :cmd:`Defined` in order to define a constant
for which the computational behavior is relevant. See :ref:`proof-editing-mode`.
+ This command accepts the :attr:`using` attribute.
+
.. note::
+ Some fixpoints may have several arguments that fit as decreasing
diff --git a/doc/sphinx/language/core/modules.rst b/doc/sphinx/language/core/modules.rst
index 866104d5d1..1309a47ff4 100644
--- a/doc/sphinx/language/core/modules.rst
+++ b/doc/sphinx/language/core/modules.rst
@@ -1001,12 +1001,12 @@ of the ``Require`` command can be used to bypass the implicit shortening
by providing an absolute root to the required file (see :ref:`compiled-files`).
There also exists another independent loadpath mechanism attached to
-OCaml object files (``.cmo`` or ``.cmxs``) rather than |Coq| object
-files as described above. The OCaml loadpath is managed using
-the option ``-I`` `path` (in the OCaml world, there is neither a
+|OCaml| object files (``.cmo`` or ``.cmxs``) rather than |Coq| object
+files as described above. The |OCaml| loadpath is managed using
+the option ``-I`` `path` (in the |OCaml| world, there is neither a
notion of logical name prefix nor a way to access files in
subdirectories of path). See the command :cmd:`Declare ML Module` in
-:ref:`compiled-files` to understand the need of the OCaml loadpath.
+:ref:`compiled-files` to understand the need of the |OCaml| loadpath.
See :ref:`command-line-options` for a more general view over the |Coq| command
line options.
diff --git a/doc/sphinx/language/core/primitive.rst b/doc/sphinx/language/core/primitive.rst
index 48647deeff..17f569ca2a 100644
--- a/doc/sphinx/language/core/primitive.rst
+++ b/doc/sphinx/language/core/primitive.rst
@@ -45,13 +45,13 @@ applications of these primitive operations.
The extraction of these primitives can be customized similarly to the extraction
of regular axioms (see :ref:`extraction`). Nonetheless, the :g:`ExtrOCamlInt63`
-module can be used when extracting to OCaml: it maps the Coq primitives to types
-and functions of a :g:`Uint63` module. Said OCaml module is not produced by
+module can be used when extracting to |OCaml|: it maps the |Coq| primitives to types
+and functions of a :g:`Uint63` module. That |OCaml| module is not produced by
extraction. Instead, it has to be provided by the user (if they want to compile
or execute the extracted code). For instance, an implementation of this module
-can be taken from the kernel of Coq.
+can be taken from the kernel of |Coq|.
-Literal values (at type :g:`Int63.int`) are extracted to literal OCaml values
+Literal values (at type :g:`Int63.int`) are extracted to literal |OCaml| values
wrapped into the :g:`Uint63.of_int` (resp. :g:`Uint63.of_int64`) constructor on
64-bit (resp. 32-bit) platforms. Currently, this cannot be customized (see the
function :g:`Uint63.compile` from the kernel).
@@ -94,13 +94,13 @@ to comply with the IEEE 754 standard for floating-point arithmetic.
The extraction of these primitives can be customized similarly to the extraction
of regular axioms (see :ref:`extraction`). Nonetheless, the :g:`ExtrOCamlFloats`
-module can be used when extracting to OCaml: it maps the Coq primitives to types
-and functions of a :g:`Float64` module. Said OCaml module is not produced by
+module can be used when extracting to |OCaml|: it maps the |Coq| primitives to types
+and functions of a :g:`Float64` module. Said |OCaml| module is not produced by
extraction. Instead, it has to be provided by the user (if they want to compile
or execute the extracted code). For instance, an implementation of this module
-can be taken from the kernel of Coq.
+can be taken from the kernel of |Coq|.
-Literal values (of type :g:`Float64.t`) are extracted to literal OCaml
+Literal values (of type :g:`Float64.t`) are extracted to literal |OCaml|
values (of type :g:`float`) written in hexadecimal notation and
wrapped into the :g:`Float64.of_float` constructor, e.g.:
:g:`Float64.of_float (0x1p+0)`.
@@ -144,19 +144,19 @@ operations.
The extraction of these primitives can be customized similarly to the extraction
of regular axioms (see :ref:`extraction`). Nonetheless, the :g:`ExtrOCamlPArray`
-module can be used when extracting to OCaml: it maps the Coq primitives to types
-and functions of a :g:`Parray` module. Said OCaml module is not produced by
+module can be used when extracting to |OCaml|: it maps the |Coq| primitives to types
+and functions of a :g:`Parray` module. Said |OCaml| module is not produced by
extraction. Instead, it has to be provided by the user (if they want to compile
or execute the extracted code). For instance, an implementation of this module
-can be taken from the kernel of Coq (see ``kernel/parray.ml``).
+can be taken from the kernel of |Coq| (see ``kernel/parray.ml``).
-Coq's primitive arrays are persistent data structures. Semantically, a set operation
+|Coq|'s primitive arrays are persistent data structures. Semantically, a set operation
``t.[i <- a]`` represents a new array that has the same values as ``t``, except
at position ``i`` where its value is ``a``. The array ``t`` still exists, can
still be used and its values were not modified. Operationally, the implementation
-of Coq's primitive arrays is optimized so that the new array ``t.[i <- a]`` does not
+of |Coq|'s primitive arrays is optimized so that the new array ``t.[i <- a]`` does not
copy all of ``t``. The details are in section 2.3 of :cite:`ConchonFilliatre07wml`.
-In short, the implementation keeps one version of ``t`` as an OCaml native array and
+In short, the implementation keeps one version of ``t`` as an |OCaml| native array and
other versions as lists of modifications to ``t``. Accesses to the native array
version are constant time operations. However, accesses to versions where all the cells of
the array are modified have O(n) access time, the same as a list. The version that is kept as the native array
diff --git a/doc/sphinx/language/core/records.rst b/doc/sphinx/language/core/records.rst
index cd44d06e67..e6df3ee9f5 100644
--- a/doc/sphinx/language/core/records.rst
+++ b/doc/sphinx/language/core/records.rst
@@ -18,27 +18,36 @@ expressions. In this sense, the :cmd:`Record` construction allows defining
.. insertprodn record_definition field_def
.. prodn::
- record_definition ::= {? > } @ident_decl {* @binder } {? : @type } {? @ident } %{ {*; @record_field } %} {? @decl_notations }
+ record_definition ::= {? > } @ident_decl {* @binder } {? : @sort } {? := {? @ident } %{ {*; @record_field } {? ; } %} }
record_field ::= {* #[ {*, @attribute } ] } @name {? @field_body } {? %| @natural } {? @decl_notations }
field_body ::= {* @binder } @of_type
| {* @binder } @of_type := @term
| {* @binder } := @term
- term_record ::= %{%| {* @field_def } %|%}
+ term_record ::= %{%| {*; @field_def } {? ; } %|%}
field_def ::= @qualid {* @binder } := @term
-
Each :n:`@record_definition` defines a record named by :n:`@ident_decl`.
The constructor name is given by :n:`@ident`.
If the constructor name is not specified, then the default name :n:`Build_@ident` is used,
where :n:`@ident` is the record name.
- If :n:`@type` is
- omitted, the default type is :math:`\Type`. The identifiers inside the brackets are the field names.
- The type of each field :n:`@ident` is :n:`forall {* @binder }, @type`.
+ If :token:`sort` is omitted, the default sort is Type.
Notice that the type of an identifier can depend on a previously-given identifier. Thus the
order of the fields is important. :n:`@binder` parameters may be applied to the record as a whole
or to individual fields.
+ .. todo
+ "Record foo2:Prop := { a }." gives the error "Cannot infer this placeholder of type "Type",
+ while "Record foo2:Prop := { a:Type }." gives the output "foo2 is defined.
+ a cannot be defined because it is informative and foo2 is not."
+ Your thoughts?
+
+ :n:`{? > }`
+ If provided, the constructor name is automatically declared as
+ a coercion from the class of the last field type to the record name
+ (this may fail if the uniform inheritance condition is not
+ satisfied). See :ref:`coercions`.
+
Notations can be attached to fields using the :n:`@decl_notations` annotation.
:cmd:`Record` and :cmd:`Structure` are synonyms.
@@ -76,7 +85,7 @@ Let us now see the work done by the ``Record`` macro. First the macro
generates a variant type definition with just one constructor:
:n:`Variant @ident {* @binder } : @sort := @ident__0 {* @binder }`.
-To build an object of type :token:`ident`, one should provide the constructor
+To build an object of type :token:`ident`, provide the constructor
:n:`@ident__0` with the appropriate number of terms filling the fields of the record.
.. example::
diff --git a/doc/sphinx/language/core/sections.rst b/doc/sphinx/language/core/sections.rst
index df50dbafe3..c70f7a347b 100644
--- a/doc/sphinx/language/core/sections.rst
+++ b/doc/sphinx/language/core/sections.rst
@@ -84,7 +84,7 @@ Sections create local contexts which can be shared across multiple definitions.
will be wrapped with a :n:`@term_let` with the same declaration.
As for :cmd:`Definition`, :cmd:`Fixpoint` and :cmd:`CoFixpoint`,
- if :n:`@term` is omitted, :n:`@type` is required and Coq enters proof editing mode.
+ if :n:`@term` is omitted, :n:`@type` is required and |Coq| enters proof editing mode.
This can be used to define a term incrementally, in particular by relying on the :tacn:`refine` tactic.
In this case, the proof should be terminated with :cmd:`Defined` in order to define a constant
for which the computational behavior is relevant. See :ref:`proof-editing-mode`.
diff --git a/doc/sphinx/language/core/variants.rst b/doc/sphinx/language/core/variants.rst
index 2904250e41..645986be9c 100644
--- a/doc/sphinx/language/core/variants.rst
+++ b/doc/sphinx/language/core/variants.rst
@@ -29,6 +29,7 @@ Private (matching) inductive types
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. attr:: private(matching)
+ :name: private(matching); Private
This attribute can be used to forbid the use of the :g:`match`
construct on objects of this inductive type outside of the module
diff --git a/doc/sphinx/language/extensions/arguments-command.rst b/doc/sphinx/language/extensions/arguments-command.rst
index 0ae9fab7ab..f8c0e23696 100644
--- a/doc/sphinx/language/extensions/arguments-command.rst
+++ b/doc/sphinx/language/extensions/arguments-command.rst
@@ -86,6 +86,7 @@ Setting properties of a function's arguments
the parameter name used in the function definition). Unless `rename` is specified,
the list of :n:`@name`\s must be a prefix of the formal parameters, including all implicit
arguments. `_` can be used to skip over a formal parameter.
+ The construct :n:`@name {? % @scope }` declares :n:`@name` as non-implicit if `clear implicits` is specified or at least one other name is declared implicit in the same list of :n:`@name`\s.
:token:`scope` can be either a scope name or its delimiting key. See :ref:`binding_to_scope`.
`clear implicits`
@@ -377,7 +378,7 @@ Effects of :cmd:`Arguments` on unfolding
Bidirectionality hints
~~~~~~~~~~~~~~~~~~~~~~
-When type-checking an application, Coq normally does not use information from
+When type-checking an application, |Coq| normally does not use information from
the context to infer the types of the arguments. It only checks after the fact
that the type inferred for the application is coherent with the expected type.
Bidirectionality hints make it possible to specify that after type-checking the
@@ -394,7 +395,7 @@ the context to help inferring the types of the remaining arguments.
* *type inference*, with is inferring the type of a construct by analyzing the construct.
Methods that combine these approaches are known as *bidirectional typing*.
- Coq normally uses only the first approach to infer the types of arguments,
+ |Coq| normally uses only the first approach to infer the types of arguments,
then later verifies that the inferred type is consistent with the expected type.
*Bidirectionality hints* specify to use both methods: after type checking the
first arguments of an application (appearing before the `&` in :cmd:`Arguments`),
@@ -416,7 +417,7 @@ type check the remaining arguments (in :n:`@arg_specs__2`).
Definition b2n (b : bool) := if b then 1 else 0.
Coercion b2n : bool >-> nat.
- Coq cannot automatically coerce existential statements over ``bool`` to
+ |Coq| cannot automatically coerce existential statements over ``bool`` to
statements over ``nat``, because the need for inserting a coercion is known
only from the expected type of a subterm:
@@ -431,7 +432,7 @@ type check the remaining arguments (in :n:`@arg_specs__2`).
Arguments ex_intro _ _ & _ _.
Check (ex_intro _ true _ : exists n : nat, n > 0).
-Coq will attempt to produce a term which uses the arguments you
+|Coq| will attempt to produce a term which uses the arguments you
provided, but in some cases involving Program mode the arguments after
the bidirectionality starts may be replaced by convertible but
syntactically different terms.
diff --git a/doc/sphinx/language/extensions/canonical.rst b/doc/sphinx/language/extensions/canonical.rst
index bfda8befff..38c9fa336d 100644
--- a/doc/sphinx/language/extensions/canonical.rst
+++ b/doc/sphinx/language/extensions/canonical.rst
@@ -159,7 +159,7 @@ of the terms that are compared.
End theory.
End EQ.
-We use Coq modules as namespaces. 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
namespace contains the definitions of the algebraic structure. To
keep the example small, the algebraic structure ``EQ.type`` we are
@@ -224,7 +224,7 @@ example work:
Fail Check forall (e : EQ.type) (a b : EQ.obj e), (a, b) == (a, b).
The error message is telling that |Coq| has no idea on how to compare
-pairs of objects. The following construction is telling Coq exactly
+pairs of objects. The following construction is telling |Coq| exactly
how to do that.
.. coqtop:: all
diff --git a/doc/sphinx/language/extensions/evars.rst b/doc/sphinx/language/extensions/evars.rst
index 20f4310d13..dc208a63a0 100644
--- a/doc/sphinx/language/extensions/evars.rst
+++ b/doc/sphinx/language/extensions/evars.rst
@@ -68,7 +68,7 @@ Inferable subterms
~~~~~~~~~~~~~~~~~~
Expressions often contain redundant pieces of information. Subterms that can be
-automatically inferred by Coq can be replaced by the symbol ``_`` and Coq will
+automatically inferred by |Coq| can be replaced by the symbol ``_`` and |Coq| will
guess the missing piece of information.
.. extracted from Gallina extensions chapter
diff --git a/doc/sphinx/language/extensions/implicit-arguments.rst b/doc/sphinx/language/extensions/implicit-arguments.rst
index f8375e93ce..9457505feb 100644
--- a/doc/sphinx/language/extensions/implicit-arguments.rst
+++ b/doc/sphinx/language/extensions/implicit-arguments.rst
@@ -115,7 +115,7 @@ application will include that argument. Otherwise, the argument is
*non-maximally inserted* and the partial application will not include that argument.
Each implicit argument can be declared to be inserted maximally or non
-maximally. In Coq, maximally inserted implicit arguments are written between curly braces
+maximally. In |Coq|, maximally inserted implicit arguments are written between curly braces
"{ }" and non-maximally inserted implicit arguments are written in square brackets "[ ]".
.. seealso:: :flag:`Maximal Implicit Insertion`
diff --git a/doc/sphinx/language/extensions/index.rst b/doc/sphinx/language/extensions/index.rst
index ed207ca743..ea7271179e 100644
--- a/doc/sphinx/language/extensions/index.rst
+++ b/doc/sphinx/language/extensions/index.rst
@@ -4,7 +4,7 @@
Language extensions
===================
-Elaboration extends the language accepted by the Coq kernel to make it
+Elaboration extends the language accepted by the |Coq| kernel to make it
easier to use. For example, this lets the user omit most type
annotations because they can be inferred, call functions with implicit
arguments which will be inferred as well, extend the syntax with
diff --git a/doc/sphinx/language/extensions/match.rst b/doc/sphinx/language/extensions/match.rst
index c36b9deef3..3c1983ee97 100644
--- a/doc/sphinx/language/extensions/match.rst
+++ b/doc/sphinx/language/extensions/match.rst
@@ -290,6 +290,43 @@ This example emphasizes what the printing settings offer.
Print snd.
+Conventions about unused pattern-matching variables
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Pattern-matching variables that are not used on the right-hand side of ``=>`` are
+considered the sign of a potential error. For instance, it could
+result from an undetected mispelled constant constructor. By default,
+a warning is issued in such situations.
+
+.. warn:: Unused variable @ident catches more than one case.
+
+ This indicates that an unused pattern variable :token:`ident`
+ occurs in a pattern-matching clause used to complete at least two
+ cases of the pattern-matching problem.
+
+ The warning can be deactivated by using a variable name starting
+ with ``_`` or by setting ``Set Warnings
+ "-unused-pattern-matching-variable"``.
+
+ Here is an example where the warning is activated.
+
+ .. example::
+
+ .. coqtop:: none
+
+ Set Warnings "-unused-pattern-matching-variable".
+
+ .. coqtop:: all
+
+ Definition is_zero (o : option nat) := match o with
+ | Some 0 => true
+ | x => false
+ end.
+
+ .. coqtop:: none
+
+ Set Warnings "+unused-pattern-matching-variable".
+
Patterns
--------
@@ -639,7 +676,7 @@ Dependent pattern matching
~~~~~~~~~~~~~~~~~~~~~~~~~~
The examples given so far do not need an explicit elimination
-predicate because all the |rhs| have the same type and Coq
+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 types
of the |rhs| are different instances of the elimination predicate. The
diff --git a/doc/sphinx/practical-tools/coq-commands.rst b/doc/sphinx/practical-tools/coq-commands.rst
index ec182ce08f..59e1c65a49 100644
--- a/doc/sphinx/practical-tools/coq-commands.rst
+++ b/doc/sphinx/practical-tools/coq-commands.rst
@@ -24,13 +24,13 @@ develop his theories and proofs step by step. The |Coq| toplevel is run
by the command ``coqtop``.
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
+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
the byte-code version.
-The byte-code toplevel is based on an OCaml toplevel (to
-allow dynamic linking of tactics). You can switch to the OCaml toplevel
+The byte-code toplevel is based on an |OCaml| toplevel (to
+allow dynamic linking of tactics). You can switch to the |OCaml| toplevel
with the command ``Drop.``, and come back to the |Coq|
toplevel with the command ``Coqloop.loop();;``.
@@ -61,7 +61,7 @@ By resource file
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
+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 it's ``~/.config``)
and ``xxx`` is the version number (e.g. 8.8). If
@@ -133,7 +133,7 @@ The following command-line options are recognized by the commands ``coqc``
and ``coqtop``, unless stated otherwise:
:-I *directory*, -include *directory*: Add physical path *directory*
- to the OCaml loadpath.
+ to the |OCaml| loadpath.
.. seealso::
@@ -253,8 +253,8 @@ and ``coqtop``, unless stated otherwise:
.. warning:: This makes the logic inconsistent.
:-mangle-names *ident*: *Experimental.* Do not depend on this option. Replace
- Coq's auto-generated name scheme with names of the form *ident0*, *ident1*,
- etc. Within Coq, the :flag:`Mangle Names` flag turns this behavior on,
+ |Coq|'s auto-generated name scheme with names of the form *ident0*, *ident1*,
+ etc. Within |Coq|, the :flag:`Mangle Names` flag turns this behavior on,
and the :opt:`Mangle Names Prefix` option sets the prefix to use. This feature
is intended to be used as a linter for developments that want to be robust to
changes in the auto-generated name scheme. The options are provided to
@@ -264,7 +264,7 @@ and ``coqtop``, unless stated otherwise:
type of the option. For flags :n:`@setting_name` is equivalent to
:n:`@setting_name=true`. For instance ``-set "Universe Polymorphism"``
will enable :flag:`Universe Polymorphism`. Note that the quotes are
- shell syntax, Coq does not see them.
+ shell syntax, |Coq| does not see them.
See the :ref:`note above <interleave-command-line>` regarding the order
of command-line options.
:-unset *string*: As ``-set`` but used to disable options and flags.
@@ -304,7 +304,7 @@ and ``coqtop``, unless stated otherwise:
Compiled interfaces (produced using ``-vos``)
----------------------------------------------
-Compiled interfaces help saving time while developing Coq formalizations,
+Compiled interfaces help saving time while developing |Coq| formalizations,
by compiling the formal statements exported by a library independently of
the proofs that it contains.
@@ -473,7 +473,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, -admit can be used to tell Coq 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 42e752841d..64b433115c 100644
--- a/doc/sphinx/practical-tools/coqide.rst
+++ b/doc/sphinx/practical-tools/coqide.rst
@@ -5,9 +5,9 @@
|Coq| Integrated Development Environment
========================================
-The Coq Integrated Development Environment is a graphical tool, to be
+The |Coq| Integrated Development Environment is a graphical tool, to be
used as a user-friendly replacement to `coqtop`. Its main purpose is to
-allow the user to navigate forward and backward into a Coq vernacular
+allow the user to navigate forward and backward into a |Coq| vernacular
file, executing corresponding commands or undoing them respectively.
|CoqIDE| is run by typing the command `coqide` on the command line.
@@ -23,7 +23,7 @@ no meaning for |CoqIDE| being ignored.
:alt: |CoqIDE| main screen
A sample |CoqIDE| main screen, while navigating into a file `Fermat.v`,
-is shown in the figure :ref:`CoqIDE main screen <coqide_mainscreen>`.
+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
@@ -39,7 +39,7 @@ The *File* menu allows you to open files or create some, save them,
print or export them into various formats. Among all these buffers,
there is always one which is the current *running buffer*, whose name
is displayed on a background in the *processed* color (green by default), which
-is the one where Coq commands are currently executed.
+is the one where |Coq| commands are currently executed.
Buffers may be edited as in any text editor, and classical basic
editing commands (Copy/Paste, …) are available in the *Edit* menu.
@@ -47,7 +47,7 @@ editing commands (Copy/Paste, …) are available in the *Edit* menu.
editing commands, you may launch your favorite text editor on the
current buffer, using the *Edit/External Editor* menu.
-Interactive navigation into Coq scripts
+Interactive navigation into |Coq| scripts
--------------------------------------------
The running buffer is the one where navigation takes place. The toolbar offers
@@ -58,7 +58,7 @@ processed color. If that command fails, the error message is displayed in the
message window, and the location of the error is emphasized by an underline in
the error foreground color (red by default).
-In the figure :ref:`CoqIDE main screen <coqide_mainscreen>`,
+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
@@ -153,7 +153,7 @@ as standard |GtkSourceView| styles are available. Other styles can be
added e.g. in ``$HOME/.local/share/gtksourceview-3.0/styles/`` (see
the general documentation about |GtkSourceView| for the various
possibilities). Note that the style of the rest of graphical part of
-Coqide is not under the control of |GtkSourceView| but of GTK+ and
+|CoqIDE| is not under the control of |GtkSourceView| but of GTK+ and
governed by files such as ``settings.ini`` and ``gtk.css`` in
``$XDG_CONFIG_HOME/gtk-3.0`` or files in
``$HOME/.themes/NameOfTheme/gtk-3.0``, as well as the environment
@@ -219,7 +219,7 @@ mathematical symbols ∀ and ∃, you may define:
: type_scope.
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
+file `utf8.v` of |Coq| library, so you may enable them just by
``Require Import Unicode.Utf8`` inside |CoqIDE|, or equivalently,
by starting |CoqIDE| with ``coqide -l utf8``.
@@ -237,7 +237,7 @@ use antialiased fonts or not, by setting the environment variable
Bindings for input of Unicode symbols
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-CoqIDE supports a builtin mechanism to input non-ASCII symbols.
+|CoqIDE| supports a builtin mechanism to input non-ASCII symbols.
For example, to input ``π``, it suffices to type ``\pi`` then press the
combination of key ``Shift+Space`` (default key binding). Often, it
suffices to type a prefix of the latex token, e.g. typing ``\p``
diff --git a/doc/sphinx/practical-tools/utilities.rst b/doc/sphinx/practical-tools/utilities.rst
index daae46ad11..c3286199e8 100644
--- a/doc/sphinx/practical-tools/utilities.rst
+++ b/doc/sphinx/practical-tools/utilities.rst
@@ -8,8 +8,8 @@ The distribution provides utilities to simplify some tedious works
beside proof development, tactics writing or documentation.
-Using Coq as a library
-----------------------
+Using |Coq| as a library
+------------------------
In previous versions, ``coqmktop`` was used to build custom
toplevels - for example for better debugging or custom static
@@ -37,10 +37,10 @@ and similarly for other plugins.
Building a |Coq| project
------------------------
-As of today it is possible to build Coq projects using two tools:
+As of today it is possible to build |Coq| projects using two tools:
-- coq_makefile, which is distributed by Coq and is based on generating a makefile,
-- Dune, the standard OCaml build tool, which, since version 1.9, supports building Coq libraries.
+- coq_makefile, which is distributed by |Coq| and is based on generating a makefile,
+- Dune, the standard |OCaml| build tool, which, since version 1.9, supports building |Coq| libraries.
.. _coq_makefile:
@@ -142,7 +142,7 @@ Here we describe only few of them.
:CAMLPKGS:
can be used to specify third party findlib packages, and is
- passed to the OCaml compiler on building or linking of modules. Eg:
+ passed to the |OCaml| compiler on building or linking of modules. Eg:
``-package yojson``.
:CAMLFLAGS:
can be used to specify additional flags to the |OCaml|
@@ -150,15 +150,15 @@ Here we describe only few of them.
:OCAMLWARN:
it contains a default of ``-warn-error +a-3``, useful to modify
this setting; beware this is not recommended for projects in
- Coq's CI.
+ |Coq|'s CI.
:COQC, COQDEP, COQDOC:
can be set in order to use alternative binaries
(e.g. wrappers)
:COQ_SRC_SUBDIRS:
can be extended by including other paths in which ``*.cm*`` files
are searched. For example ``COQ_SRC_SUBDIRS+=user-contrib/Unicoq``
- lets you build a plugin containing OCaml code that depends on the
- OCaml code of ``Unicoq``
+ lets you build a plugin containing |OCaml| code that depends on the
+ |OCaml| code of ``Unicoq``
:COQFLAGS:
override the flags passed to ``coqc``. By default ``-q``.
:COQEXTRAFLAGS:
@@ -172,7 +172,7 @@ Here we describe only few of them.
:COQDOCEXTRAFLAGS:
extend the flags passed to ``coqdoc``
:COQLIBINSTALL, COQDOCINSTALL:
- specify where the Coq libraries and documentation will be installed.
+ specify where the |Coq| libraries and documentation will be installed.
By default a combination of ``$(DESTDIR)`` (if defined) with
``$(COQLIB)/user-contrib`` and ``$(DOCDIR)/user-contrib``.
@@ -560,22 +560,22 @@ Building a |Coq| project with Dune
.. note::
- Dune's Coq support is still experimental; we strongly recommend
+ Dune's |Coq| support is still experimental; we strongly recommend
using Dune 2.3 or later.
.. note::
- The canonical documentation for the Coq Dune extension is
+ The canonical documentation for the |Coq| Dune extension is
maintained upstream; please refer to the `Dune manual
<https://dune.readthedocs.io/>`_ for up-to-date information. This
documentation is up to date for Dune 2.3.
-Building a Coq project with Dune requires setting up a Dune project
+Building a |Coq| project with Dune requires setting up a Dune project
for your files. This involves adding a ``dune-project`` and
``pkg.opam`` file to the root (``pkg.opam`` can be empty or generated
by Dune itself), and then providing ``dune`` files in the directories
your ``.v`` files are placed. For the experimental version "0.1" of
-the Coq Dune language, |Coq| library stanzas look like:
+the |Coq| Dune language, |Coq| library stanzas look like:
.. code:: scheme
@@ -592,12 +592,12 @@ the library under ``<module_prefix>``. If you declare an
``<opam_package>``, an ``.install`` file for the library will be
generated; the optional ``(modules <ordered_set_lang>)`` field allows
you to filter the list of modules, and ``(libraries
-<ocaml_libraries>)`` allows the Coq theory depend on ML plugins. For
-the moment, Dune relies on Coq's standard mechanisms (such as
-``COQPATH``) to locate installed Coq libraries.
+<ocaml_libraries>)`` allows the |Coq| theory depend on ML plugins. For
+the moment, Dune relies on |Coq|'s standard mechanisms (such as
+``COQPATH``) to locate installed |Coq| libraries.
By default Dune will skip ``.v`` files present in subdirectories. In
-order to enable the usual recursive organization of Coq projects add
+order to enable the usual recursive organization of |Coq| projects add
.. code:: scheme
@@ -611,7 +611,7 @@ of your project.
.. example::
- A typical stanza for a Coq plugin is split into two parts. An OCaml build directive, which is standard Dune:
+ A typical stanza for a |Coq| plugin is split into two parts. An |OCaml| build directive, which is standard Dune:
.. code:: scheme
@@ -623,7 +623,7 @@ of your project.
(coq.pp (modules g_equations))
- And a Coq-specific part that depends on it via the ``libraries`` field:
+ And a |Coq|-specific part that depends on it via the ``libraries`` field:
.. code:: scheme
@@ -656,10 +656,10 @@ command ``Declare ML Module``.
See the man page of ``coqdep`` for more details and options.
Both Dune and ``coq_makefile`` use ``coqdep`` to compute the
-dependencies among the files part of a Coq project.
+dependencies among the files part of a |Coq| project.
-Embedded Coq phrases inside |Latex| documents
----------------------------------------------
+Embedded |Coq| phrases inside |Latex| documents
+-----------------------------------------------
When writing documentation about a proof development, one may want
to insert |Coq| phrases inside a |Latex| document, possibly together
@@ -670,7 +670,7 @@ evaluates them, and insert the outcome of the evaluation after each
phrase.
Starting with a file ``file.tex`` containing |Coq| phrases, the ``coq-tex``
-filter produces a file named ``file.v.tex`` with the Coq outcome.
+filter produces a file named ``file.v.tex`` with the |Coq| outcome.
There are options to produce the |Coq| parts in smaller font, italic,
between horizontal rules, etc. See the man page of ``coq-tex`` for more
diff --git a/doc/sphinx/proof-engine/ltac.rst b/doc/sphinx/proof-engine/ltac.rst
index f18569c7fd..8663ac646b 100644
--- a/doc/sphinx/proof-engine/ltac.rst
+++ b/doc/sphinx/proof-engine/ltac.rst
@@ -8,7 +8,7 @@ This chapter documents the tactic language |Ltac|.
We start by giving the syntax followed by the informal
semantics. To learn more about the language and
especially about its foundations, please refer to :cite:`Del00`.
-(Note the examples in the paper won't work as-is; Coq has evolved
+(Note the examples in the paper won't work as-is; |Coq| has evolved
since the paper was written.)
.. example:: Basic tactic macros
@@ -41,7 +41,7 @@ higher precedence than `+`. Usually `a/b/c` is given the :gdef:`left associativ
interpretation `(a/b)/c` rather than the :gdef:`right associative` interpretation
`a/(b/c)`.
-In Coq, the expression :n:`try repeat @tactic__1 || @tactic__2; @tactic__3; @tactic__4`
+In |Coq|, the expression :n:`try repeat @tactic__1 || @tactic__2; @tactic__3; @tactic__4`
is interpreted as :n:`(try (repeat (@tactic__1 || @tactic__2)); @tactic__3); @tactic__4`
because `||` is part of :token:`ltac_expr2`, which has higher precedence than
:tacn:`try` and :tacn:`repeat` (at the level of :token:`ltac_expr3`), which
@@ -161,7 +161,7 @@ Syntactic values
Provides a way to use the syntax and semantics of a grammar nonterminal as a
value in an :token:`ltac_expr`. The table below describes the most useful of
these. You can see the others by running ":cmd:`Print Grammar` `tactic`" and
-examining the part at the end under "Entry tactic:tactic_arg".
+examining the part at the end under "Entry tactic:tactic_value".
:token:`ident`
name of a grammar nonterminal listed in the table
@@ -784,7 +784,7 @@ single success:
Checking for a single success: exactly_once
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Coq provides an experimental way to check that a tactic has *exactly
+|Coq| provides an experimental way to check that a tactic has *exactly
one* success:
.. tacn:: exactly_once @ltac_expr3
@@ -813,7 +813,7 @@ one* success:
Checking for failure: assert_fails
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Coq defines an |Ltac| tactic in `Init.Tactics` to check that a tactic *fails*:
+|Coq| defines an |Ltac| tactic in `Init.Tactics` to check that a tactic *fails*:
.. tacn:: assert_fails @ltac_expr3
:name: assert_fails
@@ -859,7 +859,7 @@ Coq defines an |Ltac| tactic in `Init.Tactics` to check that a tactic *fails*:
Checking for success: assert_succeeds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Coq defines an |Ltac| tactic in `Init.Tactics` to check that a tactic has *at least one*
+|Coq| defines an |Ltac| tactic in `Init.Tactics` to check that a tactic has *at least one*
success:
.. tacn:: assert_succeeds @ltac_expr3
@@ -879,7 +879,8 @@ Print/identity tactic: idtac
.. tacn:: idtac {* {| @ident | @string | @natural } }
:name: idtac
- Leaves the proof unchanged and prints the given tokens. Strings and integers are printed
+ Leaves the proof unchanged and prints the given tokens. :token:`String<string>`\s
+ and :token:`natural`\s are printed
literally. If :token:`ident` is an |Ltac| variable, its contents are printed; if not, it
is an error.
@@ -888,7 +889,7 @@ Print/identity tactic: idtac
Failing
~~~~~~~
-.. tacn:: {| fail | gfail } {? @int_or_var } {* {| @ident | @string | @integer } }
+.. tacn:: {| fail | gfail } {? @int_or_var } {* {| @ident | @string | @natural } }
:name: fail; gfail
:tacn:`fail` is the always-failing tactic: it does not solve any
@@ -904,7 +905,7 @@ Failing
See the example for a comparison of the two constructs.
- Note that if Coq terms have to be
+ Note that if |Coq| terms have to be
printed as part of the failure, term construction always forces the
tactic into the goals, meaning that if there are no goals when it is
evaluated, a tactic call like :tacn:`let` :n:`x := H in` :tacn:`fail` `0 x` will succeed.
@@ -919,7 +920,7 @@ Failing
the call to :tacn:`fail` :n:`@natural` is not enclosed in a :n:`+` construct,
respecting the algebraic identity.
- :n:`{* {| @ident | @string | @integer } }`
+ :n:`{* {| @ident | @string | @natural } }`
The given tokens are used for printing the failure message. If :token:`ident`
is an |Ltac| variable, its contents are printed; if not, it is an error.
@@ -937,7 +938,7 @@ Failing
.. todo the example is too long; could show the Goal True. Proof. once and hide the Aborts
to shorten it. And add a line of text before each subexample. Perhaps add some very short
- explanations/generalizations (eg gfail always fails; "tac; fail" succeeds but "fail." alone
+ explanations/generalizations (e.g. gfail always fails; "tac; fail" succeeds but "fail." alone
fails.
.. coqtop:: reset all fail
@@ -989,7 +990,7 @@ amount of time:
timeout with some other tacticals. This tactical is hence proposed only
for convenience during debugging or other development phases, we strongly
advise you to not leave any timeout in final scripts. Note also that
- this tactical isn’t available on the native Windows port of Coq.
+ this tactical isn’t available on the native Windows port of |Coq|.
Timing a tactic
~~~~~~~~~~~~~~~
@@ -1488,7 +1489,7 @@ Examples:
match_context_rule ::= [ {*, @match_hyp } |- @match_pattern ] => @ltac_expr
match_hyp ::= | @name := {? [ @match_pattern ] : } @match_pattern
-.. todo PR The following items (up to numgoals) are part of "value_tactic". I'd like to make
+.. todo The following items (up to numgoals) are part of "value_tactic". I'd like to make
this a subsection and explain that they all return values. How do I get a 5th-level section title?
Filling a term context
@@ -1884,7 +1885,7 @@ Proving that a list is a permutation of a second list
From Section :ref:`ltac-syntax` we know that Ltac has a primitive
notion of integers, but they are only used as arguments for
primitive tactics and we cannot make computations with them. Thus,
- instead, we use Coq's natural number type :g:`nat`.
+ instead, we use |Coq|'s natural number type :g:`nat`.
.. coqtop:: in
diff --git a/doc/sphinx/proof-engine/ltac2.rst b/doc/sphinx/proof-engine/ltac2.rst
index 773e393eb6..41f376c43d 100644
--- a/doc/sphinx/proof-engine/ltac2.rst
+++ b/doc/sphinx/proof-engine/ltac2.rst
@@ -3,8 +3,8 @@
Ltac2
=====
-The Ltac tactic language is probably one of the ingredients of the success of
-Coq, yet it is at the same time its Achilles' heel. Indeed, Ltac:
+The |Ltac| tactic language is probably one of the ingredients of the success of
+|Coq|, yet it is at the same time its Achilles' heel. Indeed, |Ltac|:
- has often unclear semantics
- is very non-uniform due to organic growth
@@ -30,7 +30,7 @@ as Ltac1.
Current limitations include:
- There are a number of tactics that are not yet supported in Ltac2 because
- the interface OCaml and/or Ltac2 notations haven't been written. See
+ the interface |OCaml| and/or Ltac2 notations haven't been written. See
:ref:`defining_tactics`.
- Missing usability features such as:
@@ -38,7 +38,6 @@ Current limitations include:
- Printing functions are limited and awkward to use. Only a few data types are
printable.
- Deep pattern matching and matching on tuples don't work.
- - If statements on Ltac2 boolean values
- A convenient way to build terms with casts through the low-level API. Because the
cast type is opaque, building terms with casts currently requires an awkward construction like the
following, which also incurs extra overhead to repeat typechecking for each
@@ -90,7 +89,7 @@ In particular, Ltac2 is:
* together with the Hindley-Milner type system
- a language featuring meta-programming facilities for the manipulation of
- Coq-side terms
+ |Coq|-side terms
- a language featuring notation facilities to help write palatable scripts
We describe these in more detail in the remainder of this document.
@@ -108,14 +107,14 @@ that ML constitutes a sweet spot in PL design, as it is relatively expressive
while not being either too lax (unlike dynamic typing) nor too strict
(unlike, say, dependent types).
-The main goal of Ltac2 is to serve as a meta-language for Coq. As such, it
+The main goal of Ltac2 is to serve as a meta-language for |Coq|. As such, it
naturally fits in the ML lineage, just as the historical ML was designed as
the tactic language for the LCF prover. It can also be seen as a general-purpose
-language, by simply forgetting about the Coq-specific features.
+language, by simply forgetting about the |Coq|-specific features.
Sticking to a standard ML type system can be considered somewhat weak for a
-meta-language designed to manipulate Coq terms. In particular, there is no
-way to statically guarantee that a Coq term resulting from an Ltac2
+meta-language designed to manipulate |Coq| terms. In particular, there is no
+way to statically guarantee that a |Coq| term resulting from an Ltac2
computation will be well-typed. This is actually a design choice, motivated
by backward compatibility with Ltac1. Instead, well-typedness is deferred to
dynamic checks, allowing many primitive functions to fail whenever they are
@@ -138,7 +137,7 @@ Type Syntax
~~~~~~~~~~~
At the level of terms, we simply elaborate on Ltac1 syntax, which is quite
-close to OCaml. Types follow the simply-typed syntax of OCaml.
+close to |OCaml|. Types follow the simply-typed syntax of |OCaml|.
.. insertprodn ltac2_type ltac2_typevar
@@ -160,7 +159,7 @@ declarations such as algebraic datatypes and records.
Built-in types include:
-- ``int``, machine integers (size not specified, in practice inherited from OCaml)
+- ``int``, machine integers (size not specified, in practice inherited from |OCaml|)
- ``string``, mutable strings
- ``'a array``, mutable arrays
- ``exn``, exceptions
@@ -201,7 +200,7 @@ One can define new types with the following commands.
:token:`tac2typ_knd` should be in the form :n:`[ {? {? %| } {+| @tac2alg_constructor } } ]`.
Without :n:`{| := | ::= }`
- Defines an abstract type for use representing data from OCaml. Not for
+ Defines an abstract type for use representing data from |OCaml|. Not for
end users.
:n:`with @tac2typ_def`
@@ -227,9 +226,9 @@ One can define new types with the following commands.
.. cmd:: Ltac2 @ external @ident : @ltac2_type := @string @string
:name: Ltac2 external
- Declares abstract terms. Frequently, these declare OCaml functions
+ Declares abstract terms. Frequently, these declare |OCaml| functions
defined in |Coq| and give their type information. They can also declare
- data structures from OCaml. This command has no use for the end user.
+ data structures from |OCaml|. This command has no use for the end user.
APIs
~~~~
@@ -345,12 +344,10 @@ Ltac2 Definitions
.. coqtop:: all
- Ltac2 mutable rec f b := match b with true => 0 | _ => f true end.
- Ltac2 Set f := fun b =>
- match b with true => 1 | _ => f true end.
+ Ltac2 mutable rec f b := if b then 0 else f true.
+ Ltac2 Set f := fun b => if b then 1 else f true.
Ltac2 Eval (f false).
- Ltac2 Set f as oldf := fun b =>
- match b with true => 2 | _ => oldf false end.
+ Ltac2 Set f as oldf := fun b => if b then 2 else oldf false.
Ltac2 Eval (f false).
In the definition, the `f` in the body is resolved statically
@@ -363,7 +360,7 @@ Reduction
~~~~~~~~~
We use the usual ML call-by-value reduction, with an otherwise unspecified
-evaluation order. This is a design choice making it compatible with OCaml,
+evaluation order. This is a design choice making it compatible with |OCaml|,
if ever we implement native compilation. The expected equations are as follows::
(fun x => t) V ≡ t{x := V} (βv)
@@ -407,7 +404,7 @@ standard IO monad as the ambient effectful world, Ltac2 is has a
tactic monad.
Note that the order of evaluation of application is *not* specified and is
-implementation-dependent, as in OCaml.
+implementation-dependent, as in |OCaml|.
We recall that the `Proofview.tactic` monad is essentially a IO monad together
with backtracking state representing the proof state.
@@ -537,8 +534,8 @@ aware of bound variables and must use heuristics to decide whether a variable
is a proper one or referring to something in the Ltac context.
Likewise, in Ltac1, constr parsing is implicit, so that ``foo 0`` is
-not ``foo`` applied to the Ltac integer expression ``0`` (Ltac does have a
-notion of integers, though it is not first-class), but rather the Coq term
+not ``foo`` applied to the Ltac integer expression ``0`` (|Ltac| does have a
+notion of integers, though it is not first-class), but rather the |Coq| term
:g:`Datatypes.O`.
The implicit parsing is confusing to users and often gives unexpected results.
@@ -570,11 +567,11 @@ Built-in quotations
The current implementation recognizes the following built-in quotations:
- ``ident``, which parses identifiers (type ``Init.ident``).
-- ``constr``, which parses Coq terms and produces an-evar free term at runtime
+- ``constr``, which parses |Coq| terms and produces an-evar free term at runtime
(type ``Init.constr``).
-- ``open_constr``, which parses Coq terms and produces a term potentially with
+- ``open_constr``, which parses |Coq| terms and produces a term potentially with
holes at runtime (type ``Init.constr`` as well).
-- ``pattern``, which parses Coq patterns and produces a pattern used for term
+- ``pattern``, which parses |Coq| patterns and produces a pattern used for term
matching (type ``Init.pattern``).
- ``reference`` Qualified names
are globalized at internalization into the corresponding global reference,
@@ -617,7 +614,7 @@ Term Antiquotations
Syntax
++++++
-One can also insert Ltac2 code into Coq terms, similar to what is possible in
+One can also insert Ltac2 code into |Coq| terms, similar to what is possible in
Ltac1.
.. prodn::
@@ -629,7 +626,7 @@ for their side-effects.
Semantics
+++++++++
-A quoted Coq term is interpreted in two phases, internalization and
+A quoted |Coq| term is interpreted in two phases, internalization and
evaluation.
- Internalization is part of the static semantics, that is, it is done at Ltac2
@@ -637,17 +634,17 @@ evaluation.
- Evaluation is part of the dynamic semantics, that is, it is done when
a term gets effectively computed by Ltac2.
-Note that typing of Coq terms is a *dynamic* process occurring at Ltac2
+Note that typing of |Coq| terms is a *dynamic* process occurring at Ltac2
evaluation time, and not at Ltac2 typing time.
Static semantics
****************
-During internalization, Coq variables are resolved and antiquotations are
-type checked as Ltac2 terms, effectively producing a ``glob_constr`` in Coq
+During internalization, |Coq| variables are resolved and antiquotations are
+type checked as Ltac2 terms, effectively producing a ``glob_constr`` in |Coq|
implementation terminology. Note that although it went through the
type checking of **Ltac2**, the resulting term has not been fully computed and
-is potentially ill-typed as a runtime **Coq** term.
+is potentially ill-typed as a runtime **|Coq|** term.
.. example::
@@ -669,7 +666,7 @@ of the corresponding term expression.
let x := '0 in constr:(1 + ltac2:(exact x))
Beware that the typing environment of antiquotations is **not**
-expanded by the Coq binders from the term.
+expanded by the |Coq| binders from the term.
.. example::
@@ -692,17 +689,17 @@ as follows.
`constr:(fun x : nat => ltac2:(exact (hyp @x)))`
-This pattern is so common that we provide dedicated Ltac2 and Coq term notations
+This pattern is so common that we provide dedicated Ltac2 and |Coq| term notations
for it.
- `&x` as an Ltac2 expression expands to `hyp @x`.
-- `&x` as a Coq constr expression expands to
+- `&x` as a |Coq| constr expression expands to
`ltac2:(Control.refine (fun () => hyp @x))`.
-In the special case where Ltac2 antiquotations appear inside a Coq term
+In the special case where Ltac2 antiquotations appear inside a |Coq| term
notation, the notation variables are systematically bound in the body
of the tactic expression with type `Ltac2.Init.preterm`. Such a type represents
-untyped syntactic Coq expressions, which can by typed in the
+untyped syntactic |Coq| expressions, which can by typed in the
current context using the `Ltac2.Constr.pretype` function.
.. example::
@@ -748,9 +745,9 @@ the notation section.
.. prodn:: term += $@lident
-In a Coq term, writing :g:`$x` is semantically equivalent to
+In a |Coq| term, writing :g:`$x` is semantically equivalent to
:g:`ltac2:(Control.refine (fun () => x))`, up to re-typechecking. It allows to
-insert in a concise way an Ltac2 variable of type :n:`constr` into a Coq term.
+insert in a concise way an Ltac2 variable of type :n:`constr` into a |Coq| term.
Match over terms
~~~~~~~~~~~~~~~~
@@ -1129,7 +1126,7 @@ Match on values
.. tacn:: match @ltac2_expr5 with {? @ltac2_branches } end
:name: match (Ltac2)
- Matches a value, akin to the OCaml `match` construct. By itself, it doesn't cause backtracking
+ Matches a value, akin to the |OCaml| `match` construct. By itself, it doesn't cause backtracking
as do the `*match*!` and `*match*! goal` constructs.
.. insertprodn ltac2_branches atomic_tac2pat
@@ -1149,6 +1146,13 @@ Match on values
| @tac2pat1 , {*, @tac2pat1 }
| @tac2pat1
+.. tacn:: if @ltac2_expr5__test then @ltac2_expr5__then else @ltac2_expr5__else
+ :name: if-then-else (Ltac2)
+
+ Equivalent to a :tacn:`match <match (Ltac2)>` on a boolean value. If the
+ :n:`@ltac2_expr5__test` evaluates to true, :n:`@ltac2_expr5__then`
+ is evaluated. Otherwise :n:`@ltac2_expr5__else` is evaluated.
+
.. note::
For now, deep pattern matching is not implemented.
@@ -1254,7 +1258,7 @@ Abbreviations
Introduces a special kind of notation, called an abbreviation,
that does not add any parsing rules. It is similar in
- spirit to Coq abbreviations (see :cmd:`Notation (abbreviation)`,
+ spirit to |Coq| abbreviations (see :cmd:`Notation (abbreviation)`,
insofar as its main purpose is to give an
absolute name to a piece of pure syntax, which can be transparently referred to
by this name as if it were a proper definition.
@@ -1281,7 +1285,7 @@ Abbreviations
Defining tactics
~~~~~~~~~~~~~~~~
-Built-in tactics (those defined in OCaml code in the |Coq| executable) and Ltac1 tactics,
+Built-in tactics (those defined in |OCaml| code in the |Coq| executable) and Ltac1 tactics,
which are defined in `.v` files, must be defined through notations. (Ltac2 tactics can be
defined with :cmd:`Ltac2`.
@@ -1795,7 +1799,7 @@ Transition from Ltac1
Owing to the use of a lot of notations, the transition should not be too
difficult. In particular, it should be possible to do it incrementally. That
said, we do *not* guarantee it will be a blissful walk either.
-Hopefully, owing to the fact Ltac2 is typed, the interactive dialogue with Coq
+Hopefully, owing to the fact Ltac2 is typed, the interactive dialogue with |Coq|
will help you.
We list the major changes and the transition strategies hereafter.
diff --git a/doc/sphinx/proof-engine/proof-handling.rst b/doc/sphinx/proof-engine/proof-handling.rst
index f90ebadb3a..7f5aacbfdb 100644
--- a/doc/sphinx/proof-engine/proof-handling.rst
+++ b/doc/sphinx/proof-engine/proof-handling.rst
@@ -1,889 +1,5 @@
-.. _proofhandling:
+:orphan:
--------------------
- Proof handling
--------------------
+.. raw:: html
-In |Coq|’s proof editing mode all top-level commands documented in
-Chapter :ref:`vernacularcommands` remain available and the user has access to specialized
-commands dealing with proof development pragmas documented in this
-section. They can also use some other specialized commands called
-*tactics*. They are the very tools allowing the user to deal with
-logical reasoning. They are documented in Chapter :ref:`tactics`.
-
-Coq user interfaces usually have a way of marking whether the user has
-switched to proof editing mode. For instance, in coqtop the prompt ``Coq <``   is changed into
-:n:`@ident <`   where :token:`ident` is the declared name of the theorem currently edited.
-
-At each stage of a proof development, one has a list of goals to
-prove. Initially, the list consists only in the theorem itself. After
-having applied some tactics, the list of goals contains the subgoals
-generated by the tactics.
-
-To each subgoal is associated a number of hypotheses called the *local context*
-of the goal. Initially, the local context contains the local variables and
-hypotheses of the current section (see Section :ref:`gallina-assumptions`) and
-the local variables and hypotheses of the theorem statement. It is enriched by
-the use of certain tactics (see e.g. :tacn:`intro`).
-
-When a proof is completed, the message ``Proof completed`` is displayed.
-One can then register this proof as a defined constant in the
-environment. Because there exists a correspondence between proofs and
-terms of λ-calculus, known as the *Curry-Howard isomorphism*
-:cite:`How80,Bar81,Gir89,H89`, |Coq| stores proofs as terms of |Cic|. Those
-terms are called *proof terms*.
-
-
-.. exn:: No focused proof.
-
- Coq raises this error message when one attempts to use a proof editing command
- out of the proof editing mode.
-
-.. _proof-editing-mode:
-
-Entering and leaving proof editing mode
----------------------------------------
-
-The proof editing mode is entered by asserting a statement, which typically is
-the assertion of a theorem using an assertion command like :cmd:`Theorem`. The
-list of assertion commands is given in :ref:`Assertions`. The command
-:cmd:`Goal` can also be used.
-
-.. cmd:: Goal @form
-
- This is intended for quick assertion of statements, without knowing in
- advance which name to give to the assertion, typically for quick
- testing of the provability of a statement. If the proof of the
- statement is eventually completed and validated, the statement is then
- bound to the name ``Unnamed_thm`` (or a variant of this name not already
- used for another statement).
-
-.. cmd:: Qed
-
- This command is available in interactive editing proof mode when the
- proof is completed. Then :cmd:`Qed` extracts a proof term from the proof
- script, switches back to Coq top-level and attaches the extracted
- proof term to the declared name of the original goal. This name is
- added to the environment as an opaque constant.
-
- .. exn:: Attempt to save an incomplete proof.
- :undocumented:
-
- .. note::
-
- Sometimes an error occurs when building the proof term, because
- tactics do not enforce completely the term construction
- constraints.
-
- The user should also be aware of the fact that since the
- proof term is completely rechecked at this point, one may have to wait
- a while when the proof is large. In some exceptional cases one may
- even incur a memory overflow.
-
-.. cmd:: Defined
-
- Same as :cmd:`Qed`, except the proof is made *transparent*, which means
- that its content can be explicitly used for type checking and that it can be
- unfolded in conversion tactics (see :ref:`performingcomputations`,
- :cmd:`Opaque`, :cmd:`Transparent`).
-
-.. cmd:: Save @ident
- :name: Save
-
- Saves a completed proof with the name :token:`ident`.
-
-.. cmd:: Admitted
-
- This command is available in interactive editing mode to give up
- the current proof and declare the initial goal as an axiom.
-
-.. cmd:: Abort
-
- This command cancels the current proof development, switching back to
- the previous proof development, or to the |Coq| toplevel if no other
- proof was edited.
-
- .. exn:: No focused proof (No proof-editing in progress).
- :undocumented:
-
- .. cmdv:: Abort @ident
-
- Aborts the editing of the proof named :token:`ident` (in case you have
- nested proofs).
-
- .. seealso:: :flag:`Nested Proofs Allowed`
-
- .. cmdv:: Abort All
-
- Aborts all current goals.
-
-.. cmd:: Proof @term
- :name: Proof `term`
-
- This command applies in proof editing mode. It is equivalent to
- :n:`exact @term. Qed.`
- That is, you have to give the full proof in one gulp, as a
- proof term (see Section :ref:`applyingtheorems`).
-
- .. warning::
-
- Use of this command is discouraged. In particular, it
- doesn't work in Proof General because it must
- immediately follow the command that opened proof mode, but
- Proof General inserts :cmd:`Unset` :flag:`Silent` before it (see
- `Proof General issue #498
- <https://github.com/ProofGeneral/PG/issues/498>`_).
-
-.. cmd:: Proof
-
- Is a no-op which is useful to delimit the sequence of tactic commands
- which start a proof, after a :cmd:`Theorem` command. It is a good practice to
- use :cmd:`Proof` as an opening parenthesis, closed in the script with a
- closing :cmd:`Qed`.
-
- .. seealso:: :cmd:`Proof with`
-
-.. cmd:: Proof using {+ @ident }
-
- This command applies in proof editing mode. It declares the set of
- section variables (see :ref:`gallina-assumptions`) used by the proof.
- At :cmd:`Qed` time, the
- system will assert that the set of section variables actually used in
- the proof is a subset of the declared one.
-
- The set of declared variables is closed under type dependency. For
- example, if ``T`` is a variable and ``a`` is a variable of type
- ``T``, then the commands ``Proof using a`` and ``Proof using T a``
- are equivalent.
-
- The set of declared variables always includes the variables used by
- the statement. In other words ``Proof using e`` is equivalent to
- ``Proof using Type + e`` for any declaration expression ``e``.
-
- .. cmdv:: Proof using {+ @ident } with @tactic
-
- Combines in a single line :cmd:`Proof with` and :cmd:`Proof using`.
-
- .. seealso:: :ref:`tactics-implicit-automation`
-
- .. cmdv:: Proof using All
-
- Use all section variables.
-
- .. cmdv:: Proof using {? Type }
-
- Use only section variables occurring in the statement.
-
- .. cmdv:: Proof using Type*
-
- The ``*`` operator computes the forward transitive closure. E.g. if the
- variable ``H`` has type ``p < 5`` then ``H`` is in ``p*`` since ``p`` occurs in the type
- of ``H``. ``Type*`` is the forward transitive closure of the entire set of
- section variables occurring in the statement.
-
- .. cmdv:: Proof using -({+ @ident })
-
- Use all section variables except the list of :token:`ident`.
-
- .. cmdv:: Proof using @collection__1 + @collection__2
-
- Use section variables from the union of both collections.
- See :ref:`nameaset` to know how to form a named collection.
-
- .. cmdv:: Proof using @collection__1 - @collection__2
-
- Use section variables which are in the first collection but not in the
- second one.
-
- .. cmdv:: Proof using @collection - ({+ @ident })
-
- Use section variables which are in the first collection but not in the
- list of :token:`ident`.
-
- .. cmdv:: Proof using @collection *
-
- Use section variables in the forward transitive closure of the collection.
- The ``*`` operator binds stronger than ``+`` and ``-``.
-
-
-Proof using options
-```````````````````
-
-The following options modify the behavior of ``Proof using``.
-
-
-.. opt:: Default Proof Using "@collection"
- :name: Default Proof Using
-
- Use :n:`@collection` as the default ``Proof using`` value. E.g. ``Set Default
- Proof Using "a b"`` will complete all ``Proof`` commands not followed by a
- ``using`` part with ``using a b``.
-
-
-.. flag:: Suggest Proof Using
-
- When :cmd:`Qed` is performed, suggest a ``using`` annotation if the user did not
- provide one.
-
-.. _`nameaset`:
-
-Name a set of section hypotheses for ``Proof using``
-````````````````````````````````````````````````````
-
-.. cmd:: Collection @ident := @collection
-
- This can be used to name a set of section
- hypotheses, with the purpose of making ``Proof using`` annotations more
- compact.
-
- .. example::
-
- Define the collection named ``Some`` containing ``x``, ``y`` and ``z``::
-
- Collection Some := x y z.
-
- Define the collection named ``Fewer`` containing only ``x`` and ``y``::
-
- Collection Fewer := Some - z
-
- Define the collection named ``Many`` containing the set union or set
- difference of ``Fewer`` and ``Some``::
-
- Collection Many := Fewer + Some
- Collection Many := Fewer - Some
-
- Define the collection named ``Many`` containing the set difference of
- ``Fewer`` and the unnamed collection ``x y``::
-
- Collection Many := Fewer - (x y)
-
-
-
-.. cmd:: Existential @natural := @term
-
- This command instantiates an existential variable. :token:`natural` is an index in
- the list of uninstantiated existential variables displayed by :cmd:`Show Existentials`.
-
- This command is intended to be used to instantiate existential
- variables when the proof is completed but some uninstantiated
- existential variables remain. To instantiate existential variables
- during proof edition, you should use the tactic :tacn:`instantiate`.
-
-.. cmd:: Grab Existential Variables
-
- This command can be run when a proof has no more goal to be solved but
- has remaining uninstantiated existential variables. It takes every
- uninstantiated existential variable and turns it into a goal.
-
-Proof modes
-```````````
-
-When entering proof mode through commands such as :cmd:`Goal` and :cmd:`Proof`,
-|Coq| picks by default the |Ltac| mode. Nonetheless, there exist other proof modes
-shipped in the standard |Coq| installation, and furthermore some plugins define
-their own proof modes. The default proof mode used when opening a proof can
-be changed using the following option.
-
-.. opt:: Default Proof Mode @string
- :name: Default Proof Mode
-
- Select the proof mode to use when starting a proof. Depending on the proof
- mode, various syntactic constructs are allowed when writing an interactive
- proof. The possible option values are listed below.
-
- - "Classic": this is the default. It activates the |Ltac| language to interact
- with the proof, and also allows vernacular commands.
-
- - "Noedit": this proof mode only allows vernacular commands. No tactic
- language is activated at all. This is the default when the prelude is not
- loaded, e.g. through the `-noinit` option for `coqc`.
-
- - "Ltac2": this proof mode is made available when requiring the Ltac2
- library, and is set to be the default when it is imported. It allows
- to use the Ltac2 language, as well as vernacular commands.
-
- - Some external plugins also define their own proof mode, which can be
- activated via this command.
-
-Navigation in the proof tree
---------------------------------
-
-.. cmd:: Undo
-
- This command cancels the effect of the last command. Thus, it
- backtracks one step.
-
-.. cmdv:: Undo @natural
-
- Repeats Undo :token:`natural` times.
-
-.. cmdv:: Restart
- :name: Restart
-
- This command restores the proof editing process to the original goal.
-
- .. exn:: No focused proof to restart.
- :undocumented:
-
-.. cmd:: Focus
-
- This focuses the attention on the first subgoal to prove and the
- printing of the other subgoals is suspended until the focused subgoal
- is solved or unfocused. This is useful when there are many current
- subgoals which clutter your screen.
-
- .. deprecated:: 8.8
-
- Prefer the use of bullets or focusing brackets (see below).
-
-.. cmdv:: Focus @natural
-
- This focuses the attention on the :token:`natural` th subgoal to prove.
-
- .. deprecated:: 8.8
-
- Prefer the use of focusing brackets with a goal selector (see below).
-
-.. cmd:: Unfocus
-
- This command restores to focus the goal that were suspended by the
- last :cmd:`Focus` command.
-
- .. deprecated:: 8.8
-
-.. cmd:: Unfocused
-
- Succeeds if the proof is fully unfocused, fails if there are some
- goals out of focus.
-
-.. _curly-braces:
-
-.. index:: {
- }
-
-.. cmd:: {| %{ | %} }
-
- The command ``{`` (without a terminating period) focuses on the first
- goal, much like :cmd:`Focus` does, however, the subproof can only be
- unfocused when it has been fully solved ( *i.e.* when there is no
- focused goal left). Unfocusing is then handled by ``}`` (again, without a
- terminating period). See also an example in the next section.
-
- Note that when a focused goal is proved a message is displayed
- together with a suggestion about the right bullet or ``}`` to unfocus it
- or focus the next one.
-
- .. cmdv:: @natural: %{
-
- This focuses on the :token:`natural`\-th subgoal to prove.
-
- .. cmdv:: [@ident]: %{
-
- This focuses on the named goal :token:`ident`.
-
- .. note::
-
- Goals are just existential variables and existential variables do not
- get a name by default. You can give a name to a goal by using :n:`refine ?[@ident]`.
- You may also wrap this in an Ltac-definition like:
-
- .. coqtop:: in
-
- Ltac name_goal name := refine ?[name].
-
- .. seealso:: :ref:`existential-variables`
-
- .. example::
-
- This first example uses the Ltac definition above, and the named goals
- only serve for documentation.
-
- .. coqtop:: all
-
- Goal forall n, n + 0 = n.
- Proof.
- induction n; [ name_goal base | name_goal step ].
- [base]: {
-
- .. coqtop:: all
-
- reflexivity.
-
- .. coqtop:: in
-
- }
-
- .. coqtop:: all
-
- [step]: {
-
- .. coqtop:: all
-
- simpl.
- f_equal.
- assumption.
- }
- Qed.
-
- This can also be a way of focusing on a shelved goal, for instance:
-
- .. coqtop:: all
-
- Goal exists n : nat, n = n.
- eexists ?[x].
- reflexivity.
- [x]: exact 0.
- Qed.
-
- .. exn:: This proof is focused, but cannot be unfocused this way.
-
- You are trying to use ``}`` but the current subproof has not been fully solved.
-
- .. exn:: No such goal (@natural).
- :undocumented:
-
- .. exn:: No such goal (@ident).
- :undocumented:
-
- .. exn:: Brackets do not support multi-goal selectors.
-
- Brackets are used to focus on a single goal given either by its position
- or by its name if it has one.
-
- .. seealso:: The error messages about bullets below.
-
-.. _bullets:
-
-Bullets
-```````
-
-Alternatively to ``{`` and ``}``, proofs can be structured with bullets. The
-use of a bullet ``b`` for the first time focuses on the first goal ``g``, the
-same bullet cannot be used again until the proof of ``g`` is completed,
-then it is mandatory to focus the next goal with ``b``. The consequence is
-that ``g`` and all goals present when ``g`` was focused are focused with the
-same bullet ``b``. See the example below.
-
-Different bullets can be used to nest levels. The scope of bullet does
-not go beyond enclosing ``{`` and ``}``, so bullets can be reused as further
-nesting levels provided they are delimited by these. Bullets are made of
-repeated ``-``, ``+`` or ``*`` symbols:
-
-.. prodn:: bullet ::= {| {+ - } | {+ + } | {+ * } }
-
-Note again that when a focused goal is proved a message is displayed
-together with a suggestion about the right bullet or ``}`` to unfocus it
-or focus the next one.
-
-.. note::
-
- In Proof General (``Emacs`` interface to |Coq|), you must use
- bullets with the priority ordering shown above to have a correct
- indentation. For example ``-`` must be the outer bullet and ``**`` the inner
- one in the example below.
-
-The following example script illustrates all these features:
-
-.. example::
-
- .. coqtop:: all
-
- Goal (((True /\ True) /\ True) /\ True) /\ True.
- Proof.
- split.
- - split.
- + split.
- ** { split.
- - trivial.
- - trivial.
- }
- ** trivial.
- + trivial.
- - assert True.
- { trivial. }
- assumption.
- Qed.
-
-.. exn:: Wrong bullet @bullet__1: Current bullet @bullet__2 is not finished.
-
- Before using bullet :n:`@bullet__1` again, you should first finish proving
- the current focused goal.
- Note that :n:`@bullet__1` and :n:`@bullet__2` may be the same.
-
-.. exn:: Wrong bullet @bullet__1: Bullet @bullet__2 is mandatory here.
-
- You must put :n:`@bullet__2` to focus on the next goal. No other bullet is
- allowed here.
-
-.. exn:: No such goal. Focus next goal with bullet @bullet.
-
- You tried to apply a tactic but no goals were under focus.
- Using :n:`@bullet` is mandatory here.
-
-.. FIXME: the :noindex: below works around a Sphinx issue.
- (https://github.com/sphinx-doc/sphinx/issues/4979)
- It should be removed once that issue is fixed.
-
-.. exn:: No such goal. Try unfocusing with %}.
- :noindex:
-
- You just finished a goal focused by ``{``, you must unfocus it with ``}``.
-
-Mandatory Bullets
-`````````````````
-
-Using :opt:`Default Goal Selector` with the ``!`` selector forces
-tactic scripts to keep focus to exactly one goal (e.g. using bullets)
-or use explicit goal selectors.
-
-Set Bullet Behavior
-```````````````````
-.. opt:: Bullet Behavior {| "None" | "Strict Subproofs" }
- :name: Bullet Behavior
-
- This option controls the bullet behavior and can take two possible values:
-
- - "None": this makes bullets inactive.
- - "Strict Subproofs": this makes bullets active (this is the default behavior).
-
-.. _requestinginformation:
-
-Requesting information
-----------------------
-
-
-.. cmd:: Show
-
- This command displays the current goals.
-
- .. exn:: No focused proof.
- :undocumented:
-
- .. cmdv:: Show @natural
-
- Displays only the :token:`natural`\-th subgoal.
-
- .. exn:: No such goal.
- :undocumented:
-
- .. cmdv:: Show @ident
-
- Displays the named goal :token:`ident`. This is useful in
- particular to display a shelved goal but only works if the
- corresponding existential variable has been named by the user
- (see :ref:`existential-variables`) as in the following example.
-
- .. example::
-
- .. coqtop:: all abort
-
- Goal exists n, n = 0.
- eexists ?[n].
- Show n.
-
- .. cmdv:: Show Proof {? Diffs {? removed } }
- :name: Show Proof
-
- Displays the proof term generated by the tactics
- that have been applied so far. If the proof is incomplete, the term
- will contain holes, which correspond to subterms which are still to be
- constructed. Each hole is an existential variable, which appears as a
- question mark followed by an identifier.
-
- Experimental: Specifying “Diffs” highlights the difference between the
- current and previous proof step. By default, the command shows the
- output once with additions highlighted. Including “removed” shows
- the output twice: once showing removals and once showing additions.
- It does not examine the :opt:`Diffs` option. See :ref:`showing_diffs`.
-
- .. cmdv:: Show Conjectures
- :name: Show Conjectures
-
- It prints the list of the names of all the
- theorems that are currently being proved. As it is possible to start
- proving a previous lemma during the proof of a theorem, this list may
- contain several names.
-
- .. cmdv:: Show Intro
- :name: Show Intro
-
- If the current goal begins by at least one product,
- this command prints the name of the first product, as it would be
- generated by an anonymous :tacn:`intro`. The aim of this command is to ease
- the writing of more robust scripts. For example, with an appropriate
- Proof General macro, it is possible to transform any anonymous :tacn:`intro`
- into a qualified one such as ``intro y13``. In the case of a non-product
- goal, it prints nothing.
-
- .. cmdv:: Show Intros
- :name: Show Intros
-
- This command is similar to the previous one, it
- simulates the naming process of an :tacn:`intros`.
-
- .. cmdv:: Show Existentials
- :name: Show Existentials
-
- Displays all open goals / existential variables in the current proof
- along with the type and the context of each variable.
-
- .. cmdv:: Show Match @ident
-
- This variant displays a template of the Gallina
- ``match`` construct with a branch for each constructor of the type
- :token:`ident`
-
- .. example::
-
- .. coqtop:: all
-
- Show Match nat.
-
- .. exn:: Unknown inductive type.
- :undocumented:
-
- .. cmdv:: Show Universes
- :name: Show Universes
-
- It displays the set of all universe constraints and
- its normalized form at the current stage of the proof, useful for
- debugging universe inconsistencies.
-
- .. cmdv:: Show Goal @natural at @natural
- :name: Show Goal
-
- This command is only available in coqtop. Displays a goal at a
- proof state using the goal ID number and the proof state ID number.
- It is primarily for use by tools such as Prooftree that need to fetch
- goal history in this way. Prooftree is a tool for visualizing a proof
- as a tree that runs in Proof General.
-
-.. cmd:: Guarded
-
- Some tactics (e.g. :tacn:`refine`) allow to build proofs using
- fixpoint or co-fixpoint constructions. Due to the incremental nature
- of interactive proof construction, the check of the termination (or
- guardedness) of the recursive calls in the fixpoint or cofixpoint
- constructions is postponed to the time of the completion of the proof.
-
- The command :cmd:`Guarded` allows checking if the guard condition for
- fixpoint and cofixpoint is violated at some time of the construction
- of the proof without having to wait the completion of the proof.
-
-.. _showing_diffs:
-
-Showing differences between proof steps
----------------------------------------
-
-
-Coq can automatically highlight the differences between successive proof steps
-and between values in some error messages. Also, as an experimental feature,
-Coq can also highlight differences between proof steps shown in the :cmd:`Show Proof`
-command, but only, for now, when using coqtop and Proof General.
-
-For example, the following screenshots of CoqIDE and coqtop show the application
-of the same :tacn:`intros` tactic. The tactic creates two new hypotheses, highlighted in green.
-The conclusion is entirely in pale green because although it’s changed, no tokens were added
-to it. The second screenshot uses the "removed" option, so it shows the conclusion a
-second time with the old text, with deletions marked in red. Also, since the hypotheses are
-new, no line of old text is shown for them.
-
-.. comment screenshot produced with:
- Inductive ev : nat -> Prop :=
- | ev_0 : ev 0
- | ev_SS : forall n : nat, ev n -> ev (S (S n)).
-
- Fixpoint double (n:nat) :=
- match n with
- | O => O
- | S n' => S (S (double n'))
- end.
-
- Goal forall n, ev n -> exists k, n = double k.
- intros n E.
-
-..
-
- .. image:: ../_static/diffs-coqide-on.png
- :alt: |CoqIDE| with Set Diffs on
-
-..
-
- .. image:: ../_static/diffs-coqide-removed.png
- :alt: |CoqIDE| with Set Diffs removed
-
-..
-
- .. image:: ../_static/diffs-coqtop-on3.png
- :alt: coqtop with Set Diffs on
-
-This image shows an error message with diff highlighting in CoqIDE:
-
-..
-
- .. image:: ../_static/diffs-error-message.png
- :alt: |CoqIDE| error message with diffs
-
-How to enable diffs
-```````````````````
-
-.. opt:: Diffs {| "on" | "off" | "removed" }
- :name: Diffs
-
- The “on” setting highlights added tokens in green, while the “removed” setting
- additionally reprints items with removed tokens in red. Unchanged tokens in
- modified items are shown with pale green or red. Diffs in error messages
- use red and green for the compared values; they appear regardless of the setting.
- (Colors are user-configurable.)
-
-For coqtop, showing diffs can be enabled when starting coqtop with the
-``-diffs on|off|removed`` command-line option or by setting the :opt:`Diffs` option
-within Coq. You will need to provide the ``-color on|auto`` command-line option when
-you start coqtop in either case.
-
-Colors for coqtop can be configured by setting the ``COQ_COLORS`` environment
-variable. See section :ref:`customization-by-environment-variables`. Diffs
-use the tags ``diff.added``, ``diff.added.bg``, ``diff.removed`` and ``diff.removed.bg``.
-
-In CoqIDE, diffs should be enabled from the ``View`` menu. Don’t use the ``Set Diffs``
-command in CoqIDE. You can change the background colors shown for diffs from the
-``Edit | Preferences | Tags`` panel by changing the settings for the ``diff.added``,
-``diff.added.bg``, ``diff.removed`` and ``diff.removed.bg`` tags. This panel also
-lets you control other attributes of the highlights, such as the foreground
-color, bold, italic, underline and strikeout.
-
-As of June 2019, Proof General can also display Coq-generated proof diffs automatically.
-Please see the PG documentation section
-"`Showing Proof Diffs" <https://proofgeneral.github.io/doc/master/userman/Coq-Proof-General#Showing-Proof-Diffs>`_)
-for details.
-
-How diffs are calculated
-````````````````````````
-
-Diffs are calculated as follows:
-
-1. Select the old proof state to compare to, which is the proof state before
- the last tactic that changed the proof. Changes that only affect the view
- of the proof, such as ``all: swap 1 2``, are ignored.
-
-2. For each goal in the new proof state, determine what old goal to compare
- it to—the one it is derived from or is the same as. Match the hypotheses by
- name (order is ignored), handling compacted items specially.
-
-3. For each hypothesis and conclusion (the “items”) in each goal, pass
- them as strings to the lexer to break them into tokens. Then apply the
- Myers diff algorithm :cite:`Myers` on the tokens and add appropriate highlighting.
-
-Notes:
-
-* Aside from the highlights, output for the "on" option should be identical
- to the undiffed output.
-* Goals completed in the last proof step will not be shown even with the
- "removed" setting.
-
-.. comment The following screenshots show diffs working with multiple goals and with compacted
- hypotheses. In the first one, notice that the goal ``P 1`` is not highlighted at
- all after the split because it has not changed.
-
- .. todo: Use this script and remove the screenshots when COQ_COLORS
- works for coqtop in sphinx
- .. coqtop:: none
-
- Set Diffs "on".
- Parameter P : nat -> Prop.
- Goal P 1 /\ P 2 /\ P 3.
-
- .. coqtop:: out
-
- split.
-
- .. coqtop:: all abort
-
- 2: split.
-
- ..
-
- .. coqtop:: none
-
- Set Diffs "on".
- Goal forall n m : nat, n + m = m + n.
- Set Diffs "on".
-
- .. coqtop:: out
-
- intros n.
-
- .. coqtop:: all abort
-
- intros m.
-
-This screen shot shows the result of applying a :tacn:`split` tactic that replaces one goal
-with 2 goals. Notice that the goal ``P 1`` is not highlighted at all after
-the split because it has not changed.
-
-..
-
- .. image:: ../_static/diffs-coqide-multigoal.png
- :alt: coqide with Set Diffs on with multiple goals
-
-This is how diffs may appear after applying a :tacn:`intro` tactic that results
-in compacted hypotheses:
-
-..
-
- .. image:: ../_static/diffs-coqide-compacted.png
- :alt: coqide with Set Diffs on with compacted hypotheses
-
-Controlling the effect of proof editing commands
-------------------------------------------------
-
-
-.. opt:: Hyps Limit @natural
- :name: Hyps Limit
-
- This option controls the maximum number of hypotheses displayed in goals
- after the application of a tactic. All the hypotheses remain usable
- in the proof development.
- When unset, it goes back to the default mode which is to print all
- available hypotheses.
-
-
-.. flag:: Nested Proofs Allowed
-
- When turned on (it is off by default), this flag enables support for nested
- proofs: a new assertion command can be inserted before the current proof is
- finished, in which case Coq will temporarily switch to the proof of this
- *nested lemma*. When the proof of the nested lemma is finished (with :cmd:`Qed`
- or :cmd:`Defined`), its statement will be made available (as if it had been
- proved before starting the previous proof) and Coq will switch back to the
- proof of the previous assertion.
-
-
-Controlling memory usage
-------------------------
-
-.. cmd:: Print Debug GC
-
- Prints heap usage statistics, which are values from the `stat` type of the `Gc` module
- described
- `here <https://caml.inria.fr/pub/docs/manual-ocaml/libref/Gc.html#TYPEstat>`_
- in the OCaml documentation.
- The `live_words`, `heap_words` and `top_heap_words` values give the basic information.
- Words are 8 bytes or 4 bytes, respectively, for 64- and 32-bit executables.
-
-When experiencing high memory usage the following commands can be used
-to force |Coq| to optimize some of its internal data structures.
-
-.. cmd:: Optimize Proof
-
- Shrink the data structure used to represent the current proof.
-
-
-.. cmd:: Optimize Heap
-
- Perform a heap compaction. This is generally an expensive operation.
- See: `OCaml Gc.compact <http://caml.inria.fr/pub/docs/manual-ocaml/libref/Gc.html#VALcompact>`_
- There is also an analogous tactic :tacn:`optimize_heap`.
-
-Memory usage parameters can be set through the :ref:`OCAMLRUNPARAM <OCAMLRUNPARAM>`
-environment variable.
+ <meta http-equiv="refresh" content="0;URL=../proofs/writing-proofs/proof-mode.html">
diff --git a/doc/sphinx/proof-engine/ssreflect-proof-language.rst b/doc/sphinx/proof-engine/ssreflect-proof-language.rst
index ca50a02562..cdbae8ade1 100644
--- a/doc/sphinx/proof-engine/ssreflect-proof-language.rst
+++ b/doc/sphinx/proof-engine/ssreflect-proof-language.rst
@@ -158,23 +158,23 @@ compatible with the rest of |Coq|, up to a few discrepancies:
generalized form, turn off the |SSR| Boolean ``if`` notation using the command:
``Close Scope boolean_if_scope``.
+ The following flags can be unset to make |SSR| more compatible with
- parts of Coq:
+ parts of |Coq|:
.. flag:: SsrRewrite
Controls whether the incompatible rewrite syntax is enabled (the default).
- Disabling the flag makes the syntax compatible with other parts of Coq.
+ Disabling the flag makes the syntax compatible with other parts of |Coq|.
.. flag:: SsrIdents
Controls whether tactics can refer to |SSR|-generated variables that are
in the form _xxx_. Scripts with explicit references to such variables
are fragile; they are prone to failure if the proof is later modified or
- if the details of variable name generation change in future releases of Coq.
+ if the details of variable name generation change in future releases of |Coq|.
The default is on, which gives an error message when the user tries to
create such identifiers. Disabling the flag generates a warning instead,
- increasing compatibility with other parts of Coq.
+ increasing compatibility with other parts of |Coq|.
|Gallina| extensions
--------------------
@@ -5724,11 +5724,11 @@ respectively.
local function definition
-.. tacv:: pose fix @fix_body
+.. tacv:: pose fix @fix_decl
local fix definition
-.. tacv:: pose cofix @fix_body
+.. tacv:: pose cofix @fix_decl
local cofix definition
diff --git a/doc/sphinx/proof-engine/tactics.rst b/doc/sphinx/proof-engine/tactics.rst
index 4b1f312105..c665026500 100644
--- a/doc/sphinx/proof-engine/tactics.rst
+++ b/doc/sphinx/proof-engine/tactics.rst
@@ -86,42 +86,36 @@ specified, the default selector is used.
Although other selectors are available, only ``all``, ``!`` or a
single natural number are valid default goal selectors.
-.. _bindingslist:
+.. _bindings:
-Bindings list
-~~~~~~~~~~~~~
+Bindings
+~~~~~~~~
-Tactics that take a term as an argument may also support a bindings list
+Tactics that take a term as an argument may also accept :token:`bindings`
to instantiate some parameters of the term by name or position.
-The general form of a term with a bindings list is
-:n:`@term with @bindings_list` where :token:`bindings_list` can take two different forms:
+The general form of a term with :token:`bindings` is
+:n:`@term__tac with @bindings` where :token:`bindings` can take two different forms:
-.. _bindings_list_grammar:
+ .. insertprodn bindings bindings
.. prodn::
- ref ::= @ident
- | @natural
- bindings_list ::= {+ (@ref := @term) }
- | {+ @term }
-
-+ In a bindings list of the form :n:`{+ (@ref:= @term)}`, :n:`@ref` is either an
- :n:`@ident` or a :n:`@natural`. The references are determined according to the type of
- :n:`@term`. If :n:`@ref` is an identifier, this identifier has to be bound in the
- type of :n:`@term` and the binding provides the tactic with an instance for the
- parameter of this name. If :n:`@ref` is a number ``n``, it refers to
- the ``n``-th non dependent premise of the :n:`@term`, as determined by the type
- of :n:`@term`.
+ bindings ::= {+ ( {| @ident | @natural } := @term ) }
+ | {+ @one_term }
+
++ In the first form, if an :token:`ident` is specified, it must be bound in the
+ type of :n:`@term` and provides the tactic with an instance for the
+ parameter of this name. If a :token:`natural` is specified, it refers to
+ the ``n``-th non dependent premise of :n:`@term__tac`.
.. exn:: No such binder.
:undocumented:
-+ A bindings list can also be a simple list of terms :n:`{* @term}`.
- In that case the references to which these terms correspond are
- determined by the tactic. In case of :tacn:`induction`, :tacn:`destruct`, :tacn:`elim`
- and :tacn:`case`, the terms have to
- provide instances for all the dependent products in the type of term while in
++ In the second form, the interpretation of the :token:`one_term`\s depend on which
+ tactic they appear in. For :tacn:`induction`, :tacn:`destruct`, :tacn:`elim`
+ and :tacn:`case`, the :token:`one_term`\s
+ provide instances for all the dependent products in the type of :n:`@term__tac` while in
the case of :tacn:`apply`, or of :tacn:`constructor` and its variants, only instances
- for the dependent products that are not bound in the conclusion of the type
+ for the dependent products that are not bound in the conclusion of :n:`@term__tac`
are required.
.. exn:: Not the right number of missing arguments.
@@ -173,11 +167,11 @@ The :n:`eqn:` construct in various tactics uses :n:`@naming_intropattern`.
Use these elementary patterns to specify a name:
* :n:`@ident` — use the specified name
-* :n:`?` — let Coq choose a name
+* :n:`?` — let |Coq| choose a name
* :n:`?@ident` — generate a name that begins with :n:`@ident`
* :n:`_` — discard the matched part (unless it is required for another
hypothesis)
-* if a disjunction pattern omits a name, such as :g:`[|H2]`, Coq will choose a name
+* if a disjunction pattern omits a name, such as :g:`[|H2]`, |Coq| will choose a name
**Splitting patterns**
@@ -682,11 +676,11 @@ Applying theorems
.. exn:: Not the right number of missing arguments.
:undocumented:
- .. tacv:: apply @term with @bindings_list
+ .. tacv:: apply @term with @bindings
This also provides apply with values for instantiating premises. Here, variables
are referred by names and non-dependent products by increasing numbers (see
- :ref:`bindings list <bindingslist>`).
+ :ref:`bindings`).
.. tacv:: apply {+, @term}
@@ -747,8 +741,8 @@ Applying theorems
tactics that backtrack often. Moreover, it does not traverse tuples as :tacn:`apply`
does.
- .. tacv:: {? simple} apply {+, @term {? with @bindings_list}}
- {? simple} eapply {+, @term {? with @bindings_list}}
+ .. tacv:: {? simple} apply {+, @term {? with @bindings}}
+ {? simple} eapply {+, @term {? with @bindings}}
:name: simple apply; simple eapply
This summarizes the different syntaxes for :tacn:`apply` and :tacn:`eapply`.
@@ -849,7 +843,7 @@ Applying theorems
.. flag:: Universal Lemma Under Conjunction
- This flag, which preserves compatibility with versions of Coq prior to
+ This flag, which preserves compatibility with versions of |Coq| prior to
8.4 is also available for :n:`apply @term in @ident` (see :tacn:`apply … in`).
.. tacn:: apply @term in @ident
@@ -888,18 +882,18 @@ Applying theorems
This applies each :token:`term` in sequence in :token:`ident`.
- .. tacv:: apply {+, @term with @bindings_list} in @ident
+ .. tacv:: apply {+, @term with @bindings} in @ident
This does the same but uses the bindings in each :n:`(@ident := @term)` to
instantiate the parameters of the corresponding type of :token:`term`
- (see :ref:`bindings list <bindingslist>`).
+ (see :ref:`bindings`).
- .. tacv:: eapply {+, @term {? with @bindings_list } } in @ident
+ .. tacv:: eapply {+, @term {? with @bindings } } in @ident
This works as :tacn:`apply … in` but turns unresolved bindings into
existential variables, if any, instead of failing.
- .. tacv:: apply {+, @term {? with @bindings_list } } in @ident as @simple_intropattern
+ .. tacv:: apply {+, @term {? with @bindings } } in @ident as @simple_intropattern
:name: apply … in … as
This works as :tacn:`apply … in` then applies the :token:`simple_intropattern`
@@ -911,8 +905,8 @@ Applying theorems
only on subterms that contain no variables to instantiate and does not
traverse tuples. See :ref:`the corresponding example <simple_apply_ex>`.
- .. tacv:: {? simple} apply {+, @term {? with @bindings_list}} in @ident {? as @simple_intropattern}
- {? simple} eapply {+, @term {? with @bindings_list}} in @ident {? as @simple_intropattern}
+ .. tacv:: {? simple} apply {+, @term {? with @bindings}} in @ident {? as @simple_intropattern}
+ {? simple} eapply {+, @term {? with @bindings}} in @ident {? as @simple_intropattern}
This summarizes the different syntactic variants of :n:`apply @term in @ident`
and :n:`eapply @term in @ident`.
@@ -938,48 +932,48 @@ Applying theorems
:g:`constructor n` where ``n`` is the number of constructors of the head
of the goal.
- .. tacv:: constructor @natural with @bindings_list
+ .. tacv:: constructor @natural with @bindings
Let ``c`` be the i-th constructor of :g:`I`, then
- :n:`constructor i with @bindings_list` is equivalent to
- :n:`intros; apply c with @bindings_list`.
+ :n:`constructor i with @bindings` is equivalent to
+ :n:`intros; apply c with @bindings`.
.. warning::
- The terms in the :token:`bindings_list` are checked in the context
+ The terms in :token:`bindings` are checked in the context
where constructor is executed and not in the context where :tacn:`apply`
is executed (the introductions are not taken into account).
- .. tacv:: split {? with @bindings_list }
+ .. tacv:: split {? with @bindings }
:name: split
This applies only if :g:`I` has a single constructor. It is then
- equivalent to :n:`constructor 1 {? with @bindings_list }`. It is
+ equivalent to :n:`constructor 1 {? with @bindings }`. It is
typically used in the case of a conjunction :math:`A \wedge B`.
- .. tacv:: exists @bindings_list
+ .. tacv:: exists @bindings
:name: exists
This applies only if :g:`I` has a single constructor. It is then equivalent
- to :n:`intros; constructor 1 with @bindings_list.` It is typically used in
+ to :n:`intros; constructor 1 with @bindings.` It is typically used in
the case of an existential quantification :math:`\exists x, P(x).`
- .. tacv:: exists {+, @bindings_list }
+ .. tacv:: exists {+, @bindings }
- This iteratively applies :n:`exists @bindings_list`.
+ This iteratively applies :n:`exists @bindings`.
.. exn:: Not an inductive goal with 1 constructor.
:undocumented:
- .. tacv:: left {? with @bindings_list }
- right {? with @bindings_list }
+ .. tacv:: left {? with @bindings }
+ right {? with @bindings }
:name: left; right
These tactics apply only if :g:`I` has two constructors, for
instance in the case of a disjunction :math:`A \vee B`.
Then, they are respectively equivalent to
- :n:`constructor 1 {? with @bindings_list }` and
- :n:`constructor 2 {? with @bindings_list }`.
+ :n:`constructor 1 {? with @bindings }` and
+ :n:`constructor 2 {? with @bindings }`.
.. exn:: Not an inductive goal with 2 constructors.
:undocumented:
@@ -1299,7 +1293,7 @@ Managing the local context
.. tacv:: set @term {? in @goal_occurrences }
This behaves as :n:`set (@ident := @term) {? in @goal_occurrences }`
- but :token:`ident` is generated by Coq.
+ but :token:`ident` is generated by |Coq|.
.. tacv:: eset (@ident {* @binder } := @term) {? in @goal_occurrences }
eset @term {? in @goal_occurrences }
@@ -1344,7 +1338,7 @@ Managing the local context
.. tacv:: pose @term
This behaves as :n:`pose (@ident := @term)` but :token:`ident` is
- generated by Coq.
+ generated by |Coq|.
.. tacv:: epose (@ident {* @binder } := @term)
epose @term
@@ -1406,7 +1400,7 @@ Controlling the proof flow
.. tacv:: assert @type
This behaves as :n:`assert (@ident : @type)` but :n:`@ident` is
- generated by Coq.
+ generated by |Coq|.
.. tacv:: assert @type by @tactic
@@ -1486,7 +1480,7 @@ Controlling the proof flow
.. tacv:: enough @type
This behaves like :n:`enough (@ident : @type)` with the name :token:`ident` of
- the hypothesis generated by Coq.
+ the hypothesis generated by |Coq|.
.. tacv:: enough @type as @simple_intropattern
@@ -1518,13 +1512,13 @@ Controlling the proof flow
list of remaining subgoal to prove.
.. tacv:: specialize (@ident {* @term}) {? as @simple_intropattern}
- specialize @ident with @bindings_list {? as @simple_intropattern}
+ specialize @ident with @bindings {? as @simple_intropattern}
:name: specialize; _
This tactic works on local hypothesis :n:`@ident`. The
premises of this hypothesis (either universal quantifications or
non-dependent implications) are instantiated by concrete terms coming either
- from arguments :n:`{* @term}` or from a :ref:`bindings list <bindingslist>`.
+ from arguments :n:`{* @term}` or from :ref:`bindings`.
In the first form the application to :n:`{* @term}` can be partial. The
first form is equivalent to :n:`assert (@ident := @ident {* @term})`. In the
second form, instantiation elements can also be partial. In this case the
@@ -1611,7 +1605,7 @@ name of the variable (here :g:`n`) is chosen based on :g:`T`.
must have given the name explicitly (see :ref:`Existential-Variables`).
.. note:: When you are referring to hypotheses which you did not name
- explicitly, be aware that Coq may make a different decision on how to
+ explicitly, be aware that |Coq| may make a different decision on how to
name the variable in the current goal and in the context of the
existential variable. This can lead to surprising behaviors.
@@ -1765,9 +1759,9 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
between :token:`term` and the value that it takes in each of the
possible cases. The name of the equation is specified
by :token:`naming_intropattern` (see :tacn:`intros`),
- in particular ``?`` can be used to let Coq generate a fresh name.
+ in particular ``?`` can be used to let |Coq| generate a fresh name.
- .. tacv:: destruct @term with @bindings_list
+ .. tacv:: destruct @term with @bindings
This behaves like :n:`destruct @term` providing explicit instances for
the dependent premises of the type of :token:`term`.
@@ -1781,9 +1775,9 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
are left as existential variables to be inferred later, in the same way
as :tacn:`eapply` does.
- .. tacv:: destruct @term using @term {? with @bindings_list }
+ .. tacv:: destruct @term using @term {? with @bindings }
- This is synonym of :n:`induction @term using @term {? with @bindings_list }`.
+ This is synonym of :n:`induction @term using @term {? with @bindings }`.
.. tacv:: destruct @term in @goal_occurrences
@@ -1792,8 +1786,8 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
clause is an occurrence clause whose syntax and behavior is described
in :ref:`occurrences sets <occurrencessets>`.
- .. tacv:: destruct @term {? with @bindings_list } {? as @or_and_intropattern_loc } {? eqn:@naming_intropattern } {? using @term {? with @bindings_list } } {? in @goal_occurrences }
- edestruct @term {? with @bindings_list } {? as @or_and_intropattern_loc } {? eqn:@naming_intropattern } {? using @term {? with @bindings_list } } {? in @goal_occurrences }
+ .. tacv:: destruct @term {? with @bindings } {? as @or_and_intropattern_loc } {? eqn:@naming_intropattern } {? using @term {? with @bindings } } {? in @goal_occurrences }
+ edestruct @term {? with @bindings } {? as @or_and_intropattern_loc } {? eqn:@naming_intropattern } {? using @term {? with @bindings } } {? in @goal_occurrences }
These are the general forms of :tacn:`destruct` and :tacn:`edestruct`.
They combine the effects of the ``with``, ``as``, ``eqn:``, ``using``,
@@ -1806,15 +1800,15 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
recursion. It behaves as :n:`elim @term` but using a case-analysis
elimination principle and not a recursive one.
-.. tacv:: case @term with @bindings_list
+.. tacv:: case @term with @bindings
- Analogous to :n:`elim @term with @bindings_list` above.
+ Analogous to :n:`elim @term with @bindings` above.
-.. tacv:: ecase @term {? with @bindings_list }
+.. tacv:: ecase @term {? with @bindings }
:name: ecase
In case the type of :n:`@term` has dependent premises, or dependent premises
- whose values are not inferable from the :n:`with @bindings_list` clause,
+ whose values are not inferable from the :n:`with @bindings` clause,
:n:`ecase` turns them into existential variables to be resolved later on.
.. tacv:: simple destruct @ident
@@ -1906,10 +1900,10 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
:n:`(p`:sub:`1` :n:`, ... , p`:sub:`n` :n:`)` can be used instead of
:n:`[ p`:sub:`1` :n:`... p`:sub:`n` :n:`]`.
-.. tacv:: induction @term with @bindings_list
+.. tacv:: induction @term with @bindings
This behaves like :tacn:`induction` providing explicit instances for the
- premises of the type of :n:`term` (see :ref:`bindings list <bindingslist>`).
+ premises of the type of :n:`term` (see :ref:`bindings`).
.. tacv:: einduction @term
:name: einduction
@@ -1926,7 +1920,7 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
It does not expect the conclusion of the type of the first :n:`@term` to be
inductive.
-.. tacv:: induction @term using @term with @bindings_list
+.. tacv:: induction @term using @term with @bindings
This behaves as :tacn:`induction … using …` but also providing instances
for the premises of the type of the second :n:`@term`.
@@ -1954,8 +1948,8 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
induction y in x |- *.
Show 2.
-.. tacv:: induction @term with @bindings_list as @or_and_intropattern_loc using @term with @bindings_list in @goal_occurrences
- einduction @term with @bindings_list as @or_and_intropattern_loc using @term with @bindings_list in @goal_occurrences
+.. tacv:: induction @term with @bindings as @or_and_intropattern_loc using @term with @bindings in @goal_occurrences
+ einduction @term with @bindings as @or_and_intropattern_loc using @term with @bindings in @goal_occurrences
These are the most general forms of :tacn:`induction` and :tacn:`einduction`. It combines the
effects of the with, as, using, and in clauses.
@@ -1978,11 +1972,11 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
products, the tactic tries to find an instance for which the elimination
lemma applies and fails otherwise.
-.. tacv:: elim @term with @bindings_list
+.. tacv:: elim @term with @bindings
:name: elim … with
Allows to give explicit instances to the premises of the type of :n:`@term`
- (see :ref:`bindings list <bindingslist>`).
+ (see :ref:`bindings`).
.. tacv:: eelim @term
:name: eelim
@@ -1991,15 +1985,15 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
existential variables to be resolved later on.
.. tacv:: elim @term using @term
- elim @term using @term with @bindings_list
+ elim @term using @term with @bindings
Allows the user to give explicitly an induction principle :n:`@term` that
is not the standard one for the underlying inductive type of :n:`@term`. The
- :n:`@bindings_list` clause allows instantiating premises of the type of
+ :n:`@bindings` clause allows instantiating premises of the type of
:n:`@term`.
-.. tacv:: elim @term with @bindings_list using @term with @bindings_list
- eelim @term with @bindings_list using @term with @bindings_list
+.. tacv:: elim @term with @bindings using @term with @bindings
+ eelim @term with @bindings using @term with @bindings
These are the most general forms of :tacn:`elim` and :tacn:`eelim`. It combines the
effects of the ``using`` clause and of the two uses of the ``with`` clause.
@@ -2148,13 +2142,13 @@ and an explanation of the underlying technique.
:n:`discriminate @ident` where :n:`@ident` is the identifier for the last
introduced hypothesis.
-.. tacv:: discriminate @term with @bindings_list
+.. tacv:: discriminate @term with @bindings
This does the same thing as :n:`discriminate @term` but using the given
bindings to instantiate parameters or hypotheses of :n:`@term`.
.. tacv:: ediscriminate @natural
- ediscriminate @term {? with @bindings_list}
+ ediscriminate @term {? with @bindings}
:name: ediscriminate; _
This works the same as :tacn:`discriminate` but if the type of :token:`term`, or the
@@ -2212,7 +2206,7 @@ and an explanation of the underlying technique.
different types :g:`(P t`:sub:`1` :g:`... t`:sub:`n` :g:`)` and
:g:`(P u`:sub:`1` :g:`... u`:sub:`n` :sub:`)`. If :g:`t`:sub:`1` and
:g:`u`:sub:`1` are the same and have for type an inductive type for which a decidable
- equality has been declared using the command :cmd:`Scheme Equality`
+ equality has been declared using :cmd:`Scheme` :n:`Equality ...`
(see :ref:`proofschemes-induction-principles`),
the use of a sigma type is avoided.
@@ -2237,13 +2231,13 @@ and an explanation of the underlying technique.
:n:`injection @ident` where :n:`@ident` is the identifier for the last
introduced hypothesis.
- .. tacv:: injection @term with @bindings_list
+ .. tacv:: injection @term with @bindings
This does the same as :n:`injection @term` but using the given bindings to
instantiate parameters or hypotheses of :n:`@term`.
.. tacv:: einjection @natural
- einjection @term {? with @bindings_list}
+ einjection @term {? with @bindings}
:name: einjection; _
This works the same as :n:`injection` but if the type of :n:`@term`, or the
@@ -2258,10 +2252,10 @@ and an explanation of the underlying technique.
.. exn:: goal does not satisfy the expected preconditions.
:undocumented:
- .. tacv:: injection @term {? with @bindings_list} as {+ @simple_intropattern}
+ .. tacv:: injection @term {? with @bindings} as {+ @simple_intropattern}
injection @natural as {+ @simple_intropattern}
injection as {+ @simple_intropattern}
- einjection @term {? with @bindings_list} as {+ @simple_intropattern}
+ einjection @term {? with @bindings} as {+ @simple_intropattern}
einjection @natural as {+ @simple_intropattern}
einjection as {+ @simple_intropattern}
@@ -2273,10 +2267,10 @@ and an explanation of the underlying technique.
to the number of new equalities. The original equality is erased if it
corresponds to a hypothesis.
- .. tacv:: injection @term {? with @bindings_list} as @injection_intropattern
+ .. tacv:: injection @term {? with @bindings} as @injection_intropattern
injection @natural as @injection_intropattern
injection as @injection_intropattern
- einjection @term {? with @bindings_list} as @injection_intropattern
+ einjection @term {? with @bindings} as @injection_intropattern
einjection @natural as @injection_intropattern
einjection as @injection_intropattern
@@ -2359,7 +2353,7 @@ and an explanation of the underlying technique.
``inversion`` generally behaves in a slightly more expectable way than
``inversion`` (no artificial duplication of some hypotheses referring to
other hypotheses). To take benefit of these improvements, it is enough to use
- ``inversion ... as []``, letting the names being finally chosen by Coq.
+ ``inversion ... as []``, letting the names being finally chosen by |Coq|.
.. example::
@@ -2669,1760 +2663,6 @@ and an explanation of the underlying technique.
simultaneously proved are respectively :g:`forall binder ... binder, type`
The identifiers :n:`@ident` are the names of the coinduction hypotheses.
-.. _rewritingexpressions:
-
-Rewriting expressions
----------------------
-
-These tactics use the equality :g:`eq:forall A:Type, A->A->Prop` defined in
-file ``Logic.v`` (see :ref:`coq-library-logic`). The notation for :g:`eq T t u` is
-simply :g:`t=u` dropping the implicit type of :g:`t` and :g:`u`.
-
-.. tacn:: rewrite @term
- :name: rewrite
-
- This tactic applies to any goal. The type of :token:`term` must have the form
-
- ``forall (x``:sub:`1` ``:A``:sub:`1` ``) ... (x``:sub:`n` ``:A``:sub:`n` ``), eq term``:sub:`1` ``term``:sub:`2` ``.``
-
- where :g:`eq` is the Leibniz equality or a registered setoid equality.
-
- Then :n:`rewrite @term` finds the first subterm matching `term`\ :sub:`1` in the goal,
- resulting in instances `term`:sub:`1`' and `term`:sub:`2`' and then
- replaces every occurrence of `term`:subscript:`1`' by `term`:subscript:`2`'.
- Hence, some of the variables :g:`x`\ :sub:`i` are solved by unification,
- and some of the types :g:`A`\ :sub:`1`:g:`, ..., A`\ :sub:`n` become new
- subgoals.
-
- .. exn:: The @term provided does not end with an equation.
- :undocumented:
-
- .. exn:: Tactic generated a subgoal identical to the original goal. This happens if @term does not occur in the goal.
- :undocumented:
-
- .. tacv:: rewrite -> @term
-
- Is equivalent to :n:`rewrite @term`
-
- .. tacv:: rewrite <- @term
-
- Uses the equality :n:`@term`:sub:`1` :n:`= @term` :sub:`2` from right to left
-
- .. tacv:: rewrite @term in @goal_occurrences
-
- Analogous to :n:`rewrite @term` but rewriting is done following
- the clause :token:`goal_occurrences`. For instance:
-
- + :n:`rewrite H in H'` will rewrite `H` in the hypothesis
- ``H'`` instead of the current goal.
- + :n:`rewrite H in H' at 1, H'' at - 2 |- *` means
- :n:`rewrite H; rewrite H in H' at 1; rewrite H in H'' at - 2.`
- In particular a failure will happen if any of these three simpler tactics
- fails.
- + :n:`rewrite H in * |-` will do :n:`rewrite H in H'` for all hypotheses
- :g:`H'` different from :g:`H`.
- A success will happen as soon as at least one of these simpler tactics succeeds.
- + :n:`rewrite H in *` is a combination of :n:`rewrite H` and :n:`rewrite H in * |-`
- that succeeds if at least one of these two tactics succeeds.
-
- Orientation :g:`->` or :g:`<-` can be inserted before the :token:`term` to rewrite.
-
- .. tacv:: rewrite @term at @occurrences
-
- Rewrite only the given :token:`occurrences` of :token:`term`. Occurrences are
- specified from left to right as for pattern (:tacn:`pattern`). The rewrite is
- always performed using setoid rewriting, even for Leibniz’s equality, so one
- has to ``Import Setoid`` to use this variant.
-
- .. tacv:: rewrite @term by @tactic
-
- Use tactic to completely solve the side-conditions arising from the
- :tacn:`rewrite`.
-
- .. tacv:: rewrite {+, @orientation @term} {? in @ident }
-
- Is equivalent to the `n` successive tactics :n:`{+; rewrite @term}`, each one
- working on the first subgoal generated by the previous one. An :production:`orientation`
- ``->`` or ``<-`` can be inserted before each :token:`term` to rewrite. One
- unique clause can be added at the end after the keyword in; it will then
- affect all rewrite operations.
-
- In all forms of rewrite described above, a :token:`term` to rewrite can be
- immediately prefixed by one of the following modifiers:
-
- + `?` : the tactic :n:`rewrite ?@term` performs the rewrite of :token:`term` as many
- times as possible (perhaps zero time). This form never fails.
- + :n:`@natural?` : works similarly, except that it will do at most :token:`natural` rewrites.
- + `!` : works as `?`, except that at least one rewrite should succeed, otherwise
- the tactic fails.
- + :n:`@natural!` (or simply :n:`@natural`) : precisely :token:`natural` rewrites of :token:`term` will be done,
- leading to failure if these :token:`natural` rewrites are not possible.
-
- .. tacv:: erewrite @term
- :name: erewrite
-
- This tactic works as :n:`rewrite @term` but turning
- unresolved bindings into existential variables, if any, instead of
- failing. It has the same variants as :tacn:`rewrite` has.
-
- .. flag:: Keyed Unification
-
- Makes higher-order unification used by :tacn:`rewrite` rely on a set of keys to drive
- unification. The subterms, considered as rewriting candidates, must start with
- the same key as the left- or right-hand side of the lemma given to rewrite, and the arguments
- are then unified up to full reduction.
-
-.. tacn:: replace @term with @term’
- :name: replace
-
- This tactic applies to any goal. It replaces all free occurrences of :n:`@term`
- in the current goal with :n:`@term’` and generates an equality :n:`@term = @term’`
- as a subgoal. This equality is automatically solved if it occurs among
- the assumptions, or if its symmetric form occurs. It is equivalent to
- :n:`cut @term = @term’; [intro H`:sub:`n` :n:`; rewrite <- H`:sub:`n` :n:`; clear H`:sub:`n`:n:`|| assumption || symmetry; try assumption]`.
-
- .. exn:: Terms do not have convertible types.
- :undocumented:
-
- .. tacv:: replace @term with @term’ by @tactic
-
- This acts as :n:`replace @term with @term’` but applies :token:`tactic` to solve the generated
- subgoal :n:`@term = @term’`.
-
- .. tacv:: replace @term
-
- Replaces :n:`@term` with :n:`@term’` using the first assumption whose type has
- the form :n:`@term = @term’` or :n:`@term’ = @term`.
-
- .. tacv:: replace -> @term
-
- Replaces :n:`@term` with :n:`@term’` using the first assumption whose type has
- the form :n:`@term = @term’`
-
- .. tacv:: replace <- @term
-
- Replaces :n:`@term` with :n:`@term’` using the first assumption whose type has
- the form :n:`@term’ = @term`
-
- .. tacv:: replace @term {? with @term} in @goal_occurrences {? by @tactic}
- replace -> @term in @goal_occurrences
- replace <- @term in @goal_occurrences
-
- Acts as before but the replacements take place in the specified clauses
- (:token:`goal_occurrences`) (see :ref:`performingcomputations`) and not
- only in the conclusion of the goal. The clause argument must not contain
- any ``type of`` nor ``value of``.
-
-.. tacn:: subst @ident
- :name: subst
-
- This tactic applies to a goal that has :n:`@ident` in its context and (at
- least) one hypothesis, say :g:`H`, of type :n:`@ident = t` or :n:`t = @ident`
- with :n:`@ident` not occurring in :g:`t`. Then it replaces :n:`@ident` by
- :g:`t` everywhere in the goal (in the hypotheses and in the conclusion) and
- clears :n:`@ident` and :g:`H` from the context.
-
- If :n:`@ident` is a local definition of the form :n:`@ident := t`, it is also
- unfolded and cleared.
-
- If :n:`@ident` is a section variable it is expected to have no
- indirect occurrences in the goal, i.e. that no global declarations
- implicitly depending on the section variable must be present in the
- goal.
-
- .. note::
- + When several hypotheses have the form :n:`@ident = t` or :n:`t = @ident`, the
- first one is used.
-
- + If :g:`H` is itself dependent in the goal, it is replaced by the proof of
- reflexivity of equality.
-
- .. tacv:: subst {+ @ident}
-
- This is equivalent to :n:`subst @ident`:sub:`1`:n:`; ...; subst @ident`:sub:`n`.
-
- .. tacv:: subst
-
- This applies :tacn:`subst` repeatedly from top to bottom to all hypotheses of the
- context for which an equality of the form :n:`@ident = t` or :n:`t = @ident`
- or :n:`@ident := t` exists, with :n:`@ident` not occurring in
- ``t`` and :n:`@ident` not a section variable with indirect
- dependencies in the goal.
-
- .. flag:: Regular Subst Tactic
-
- This flag controls the behavior of :tacn:`subst`. When it is
- activated (it is by default), :tacn:`subst` also deals with the following corner cases:
-
- + A context with ordered hypotheses :n:`@ident`:sub:`1` :n:`= @ident`:sub:`2`
- and :n:`@ident`:sub:`1` :n:`= t`, or :n:`t′ = @ident`:sub:`1`` with `t′` not
- a variable, and no other hypotheses of the form :n:`@ident`:sub:`2` :n:`= u`
- or :n:`u = @ident`:sub:`2`; without the flag, a second call to
- subst would be necessary to replace :n:`@ident`:sub:`2` by `t` or
- `t′` respectively.
- + The presence of a recursive equation which without the flag would
- be a cause of failure of :tacn:`subst`.
- + A context with cyclic dependencies as with hypotheses :n:`@ident`:sub:`1` :n:`= f @ident`:sub:`2`
- and :n:`@ident`:sub:`2` :n:`= g @ident`:sub:`1` which without the
- flag would be a cause of failure of :tacn:`subst`.
-
- Additionally, it prevents a local definition such as :n:`@ident := t` to be
- unfolded which otherwise it would exceptionally unfold in configurations
- containing hypotheses of the form :n:`@ident = u`, or :n:`u′ = @ident`
- with `u′` not a variable. Finally, it preserves the initial order of
- hypotheses, which without the flag it may break.
- default.
-
- .. exn:: Cannot find any non-recursive equality over :n:`@ident`.
- :undocumented:
-
- .. exn:: Section variable :n:`@ident` occurs implicitly in global declaration :n:`@qualid` present in hypothesis :n:`@ident`.
- Section variable :n:`@ident` occurs implicitly in global declaration :n:`@qualid` present in the conclusion.
-
- Raised when the variable is a section variable with indirect
- dependencies in the goal.
-
-
-.. tacn:: stepl @term
- :name: stepl
-
- This tactic is for chaining rewriting steps. It assumes a goal of the
- form :n:`R @term @term` where ``R`` is a binary relation and relies on a
- database of lemmas of the form :g:`forall x y z, R x y -> eq x z -> R z y`
- where `eq` is typically a setoid equality. The application of :n:`stepl @term`
- then replaces the goal by :n:`R @term @term` and adds a new goal stating
- :n:`eq @term @term`.
-
- .. cmd:: Declare Left Step @term
-
- Adds :n:`@term` to the database used by :tacn:`stepl`.
-
- This tactic is especially useful for parametric setoids which are not accepted
- as regular setoids for :tacn:`rewrite` and :tacn:`setoid_replace` (see
- :ref:`Generalizedrewriting`).
-
- .. tacv:: stepl @term by @tactic
-
- This applies :n:`stepl @term` then applies :token:`tactic` to the second goal.
-
- .. tacv:: stepr @term by @tactic
- :name: stepr
-
- This behaves as :tacn:`stepl` but on the right-hand-side of the binary
- relation. Lemmas are expected to be of the form
- :g:`forall x y z, R x y -> eq y z -> R x z`.
-
- .. cmd:: Declare Right Step @term
-
- Adds :n:`@term` to the database used by :tacn:`stepr`.
-
-
-.. tacn:: change @term
- :name: change
-
- This tactic applies to any goal. It implements the rule ``Conv`` given in
- :ref:`subtyping-rules`. :g:`change U` replaces the current goal `T`
- with `U` providing that `U` is well-formed and that `T` and `U` are
- convertible.
-
- .. exn:: Not convertible.
- :undocumented:
-
- .. tacv:: change @term with @term’
-
- This replaces the occurrences of :n:`@term` by :n:`@term’` in the current goal.
- The term :n:`@term` and :n:`@term’` must be convertible.
-
- .. tacv:: change @term at {+ @natural} with @term’
-
- This replaces the occurrences numbered :n:`{+ @natural}` of :n:`@term` by :n:`@term’`
- in the current goal. The terms :n:`@term` and :n:`@term’` must be convertible.
-
- .. exn:: Too few occurrences.
- :undocumented:
-
- .. tacv:: change @term {? {? at {+ @natural}} with @term} in @ident
-
- This applies the :tacn:`change` tactic not to the goal but to the hypothesis :n:`@ident`.
-
- .. tacv:: now_show @term
-
- This is a synonym of :n:`change @term`. It can be used to
- make some proof steps explicit when refactoring a proof script
- to make it readable.
-
- .. seealso:: :ref:`Performing computations <performingcomputations>`
-
-.. _performingcomputations:
-
-Performing computations
----------------------------
-
-.. insertprodn red_expr pattern_occ
-
-.. prodn::
- red_expr ::= red
- | hnf
- | simpl {? @delta_flag } {? @ref_or_pattern_occ }
- | cbv {? @strategy_flag }
- | cbn {? @strategy_flag }
- | lazy {? @strategy_flag }
- | compute {? @delta_flag }
- | vm_compute {? @ref_or_pattern_occ }
- | native_compute {? @ref_or_pattern_occ }
- | unfold {+, @unfold_occ }
- | fold {+ @one_term }
- | pattern {+, @pattern_occ }
- | @ident
- delta_flag ::= {? - } [ {+ @reference } ]
- strategy_flag ::= {+ @red_flag }
- | @delta_flag
- red_flag ::= beta
- | iota
- | match
- | fix
- | cofix
- | zeta
- | delta {? @delta_flag }
- ref_or_pattern_occ ::= @reference {? at @occs_nums }
- | @one_term {? at @occs_nums }
- occs_nums ::= {+ {| @natural | @ident } }
- | - {| @natural | @ident } {* @int_or_var }
- int_or_var ::= @integer
- | @ident
- unfold_occ ::= @reference {? at @occs_nums }
- pattern_occ ::= @one_term {? at @occs_nums }
-
-This set of tactics implements different specialized usages of the
-tactic :tacn:`change`.
-
-All conversion tactics (including :tacn:`change`) can be parameterized by the
-parts of the goal where the conversion can occur. This is done using
-*goal clauses* which consists in a list of hypotheses and, optionally,
-of a reference to the conclusion of the goal. For defined hypothesis
-it is possible to specify if the conversion should occur on the type
-part, the body part or both (default).
-
-Goal clauses are written after a conversion tactic (tactics :tacn:`set`,
-:tacn:`rewrite`, :tacn:`replace` and :tacn:`autorewrite` also use goal
-clauses) and are introduced by the keyword `in`. If no goal clause is
-provided, the default is to perform the conversion only in the
-conclusion.
-
-The syntax and description of the various goal clauses is the
-following:
-
-+ :n:`in {+ @ident} |-` only in hypotheses :n:`{+ @ident}`
-+ :n:`in {+ @ident} |- *` in hypotheses :n:`{+ @ident}` and in the
- conclusion
-+ :n:`in * |-` in every hypothesis
-+ :n:`in *` (equivalent to in :n:`* |- *`) everywhere
-+ :n:`in (type of @ident) (value of @ident) ... |-` in type part of
- :n:`@ident`, in the value part of :n:`@ident`, etc.
-
-For backward compatibility, the notation :n:`in {+ @ident}` performs
-the conversion in hypotheses :n:`{+ @ident}`.
-
-.. tacn:: cbv {? @strategy_flag }
- lazy {? @strategy_flag }
- :name: cbv; lazy
-
- These parameterized reduction tactics apply to any goal and perform
- the normalization of the goal according to the specified flags. In
- correspondence with the kinds of reduction considered in Coq namely
- :math:`\beta` (reduction of functional application), :math:`\delta`
- (unfolding of transparent constants, see :ref:`vernac-controlling-the-reduction-strategies`),
- :math:`\iota` (reduction of
- pattern matching over a constructed term, and unfolding of :g:`fix` and
- :g:`cofix` expressions) and :math:`\zeta` (contraction of local definitions), the
- flags are either ``beta``, ``delta``, ``match``, ``fix``, ``cofix``,
- ``iota`` or ``zeta``. The ``iota`` flag is a shorthand for ``match``, ``fix``
- and ``cofix``. The ``delta`` flag itself can be refined into
- :n:`delta [ {+ @qualid} ]` or :n:`delta - [ {+ @qualid} ]`, restricting in the first
- case the constants to unfold to the constants listed, and restricting in the
- second case the constant to unfold to all but the ones explicitly mentioned.
- Notice that the ``delta`` flag does not apply to variables bound by a let-in
- construction inside the :n:`@term` itself (use here the ``zeta`` flag). In
- any cases, opaque constants are not unfolded (see :ref:`vernac-controlling-the-reduction-strategies`).
-
- Normalization according to the flags is done by first evaluating the
- head of the expression into a *weak-head* normal form, i.e. until the
- evaluation is blocked by a variable (or an opaque constant, or an
- axiom), as e.g. in :g:`x u1 ... un` , or :g:`match x with ... end`, or
- :g:`(fix f x {struct x} := ...) x`, or is a constructed form (a
- :math:`\lambda`-expression, a constructor, a cofixpoint, an inductive type, a
- product type, a sort), or is a redex that the flags prevent to reduce. Once a
- weak-head normal form is obtained, subterms are recursively reduced using the
- same strategy.
-
- Reduction to weak-head normal form can be done using two strategies:
- *lazy* (``lazy`` tactic), or *call-by-value* (``cbv`` tactic). The lazy
- strategy is a call-by-need strategy, with sharing of reductions: the
- arguments of a function call are weakly evaluated only when necessary,
- and if an argument is used several times then it is weakly computed
- only once. This reduction is efficient for reducing expressions with
- dead code. For instance, the proofs of a proposition :g:`exists x. P(x)`
- reduce to a pair of a witness :g:`t`, and a proof that :g:`t` satisfies the
- predicate :g:`P`. Most of the time, :g:`t` may be computed without computing
- the proof of :g:`P(t)`, thanks to the lazy strategy.
-
- The call-by-value strategy is the one used in ML languages: the
- arguments of a function call are systematically weakly evaluated
- first. Despite the lazy strategy always performs fewer reductions than
- the call-by-value strategy, the latter is generally more efficient for
- evaluating purely computational expressions (i.e. with little dead code).
-
-.. tacv:: compute
- cbv
- :name: compute; _
-
- These are synonyms for ``cbv beta delta iota zeta``.
-
-.. tacv:: lazy
-
- This is a synonym for ``lazy beta delta iota zeta``.
-
-.. tacv:: compute [ {+ @qualid} ]
- cbv [ {+ @qualid} ]
-
- These are synonyms of :n:`cbv beta delta {+ @qualid} iota zeta`.
-
-.. tacv:: compute - [ {+ @qualid} ]
- cbv - [ {+ @qualid} ]
-
- These are synonyms of :n:`cbv beta delta -{+ @qualid} iota zeta`.
-
-.. tacv:: lazy [ {+ @qualid} ]
- lazy - [ {+ @qualid} ]
-
- These are respectively synonyms of :n:`lazy beta delta {+ @qualid} iota zeta`
- and :n:`lazy beta delta -{+ @qualid} iota zeta`.
-
-.. tacv:: vm_compute
- :name: vm_compute
-
- This tactic evaluates the goal using the optimized call-by-value evaluation
- bytecode-based virtual machine described in :cite:`CompiledStrongReduction`.
- This algorithm is dramatically more efficient than the algorithm used for the
- :tacn:`cbv` tactic, but it cannot be fine-tuned. It is especially interesting for
- full evaluation of algebraic objects. This includes the case of
- reflection-based tactics.
-
-.. tacv:: native_compute
- :name: native_compute
-
- This tactic evaluates the goal by compilation to OCaml as described
- in :cite:`FullReduction`. If Coq is running in native code, it can be
- typically two to five times faster than :tacn:`vm_compute`. Note however that the
- compilation cost is higher, so it is worth using only for intensive
- computations.
-
- .. flag:: NativeCompute Timing
-
- This flag causes all calls to the native compiler to print
- timing information for the conversion to native code,
- compilation, execution, and reification phases of native
- compilation. Timing is printed in units of seconds of
- wall-clock time.
-
- .. flag:: NativeCompute Profiling
-
- On Linux, if you have the ``perf`` profiler installed, this flag makes
- it possible to profile :tacn:`native_compute` evaluations.
-
- .. opt:: NativeCompute Profile Filename @string
- :name: NativeCompute Profile Filename
-
- This option specifies the profile output; the default is
- ``native_compute_profile.data``. The actual filename used
- will contain extra characters to avoid overwriting an existing file; that
- filename is reported to the user.
- That means you can individually profile multiple uses of
- :tacn:`native_compute` in a script. From the Linux command line, run ``perf report``
- on the profile file to see the results. Consult the ``perf`` documentation
- for more details.
-
-.. flag:: Debug Cbv
-
- This flag makes :tacn:`cbv` (and its derivative :tacn:`compute`) print
- information about the constants it encounters and the unfolding decisions it
- makes.
-
-.. tacn:: red
- :name: red
-
- This tactic applies to a goal that has the form::
-
- forall (x:T1) ... (xk:Tk), T
-
- with :g:`T` :math:`\beta`:math:`\iota`:math:`\zeta`-reducing to :g:`c t`:sub:`1` :g:`... t`:sub:`n` and :g:`c` a
- constant. If :g:`c` is transparent then it replaces :g:`c` with its
- definition (say :g:`t`) and then reduces
- :g:`(t t`:sub:`1` :g:`... t`:sub:`n` :g:`)` according to :math:`\beta`:math:`\iota`:math:`\zeta`-reduction rules.
-
-.. exn:: Not reducible.
- :undocumented:
-
-.. exn:: No head constant to reduce.
- :undocumented:
-
-.. tacn:: hnf
- :name: hnf
-
- This tactic applies to any goal. It replaces the current goal with its
- head normal form according to the :math:`\beta`:math:`\delta`:math:`\iota`:math:`\zeta`-reduction rules, i.e. it
- reduces the head of the goal until it becomes a product or an
- irreducible term. All inner :math:`\beta`:math:`\iota`-redexes are also reduced.
- The behavior of both :tacn:`hnf` can be tuned using the :cmd:`Arguments` command.
-
- Example: The term :g:`fun n : nat => S n + S n` is not reduced by :n:`hnf`.
-
-.. note::
- The :math:`\delta` rule only applies to transparent constants (see :ref:`vernac-controlling-the-reduction-strategies`
- on transparency and opacity).
-
-.. tacn:: cbn
- simpl
- :name: cbn; simpl
-
- These tactics apply to any goal. They try to reduce a term to
- something still readable instead of fully normalizing it. They perform
- a sort of strong normalization with two key differences:
-
- + They unfold a constant if and only if it leads to a :math:`\iota`-reduction,
- i.e. reducing a match or unfolding a fixpoint.
- + While reducing a constant unfolding to (co)fixpoints, the tactics
- use the name of the constant the (co)fixpoint comes from instead of
- the (co)fixpoint definition in recursive calls.
-
- The :tacn:`cbn` tactic is claimed to be a more principled, faster and more
- predictable replacement for :tacn:`simpl`.
-
- The :tacn:`cbn` tactic accepts the same flags as :tacn:`cbv` and
- :tacn:`lazy`. The behavior of both :tacn:`simpl` and :tacn:`cbn`
- can be tuned using the :cmd:`Arguments` command.
-
- .. todo add "See <subsection about controlling the behavior of reduction strategies>"
- to TBA section
-
- Notice that only transparent constants whose name can be reused in the
- recursive calls are possibly unfolded by :tacn:`simpl`. For instance a
- constant defined by :g:`plus' := plus` is possibly unfolded and reused in
- the recursive calls, but a constant such as :g:`succ := plus (S O)` is
- never unfolded. This is the main difference between :tacn:`simpl` and :tacn:`cbn`.
- The tactic :tacn:`cbn` reduces whenever it will be able to reuse it or not:
- :g:`succ t` is reduced to :g:`S t`.
-
-.. tacv:: cbn [ {+ @qualid} ]
- cbn - [ {+ @qualid} ]
-
- These are respectively synonyms of :n:`cbn beta delta [ {+ @qualid} ] iota zeta`
- and :n:`cbn beta delta - [ {+ @qualid} ] iota zeta` (see :tacn:`cbn`).
-
-.. tacv:: simpl @pattern
-
- This applies :tacn:`simpl` only to the subterms matching
- :n:`@pattern` in the current goal.
-
-.. tacv:: simpl @pattern at {+ @natural}
-
- This applies :tacn:`simpl` only to the :n:`{+ @natural}` occurrences of the subterms
- matching :n:`@pattern` in the current goal.
-
- .. exn:: Too few occurrences.
- :undocumented:
-
-.. tacv:: simpl @qualid
- simpl @string
-
- This applies :tacn:`simpl` only to the applicative subterms whose head occurrence
- is the unfoldable constant :n:`@qualid` (the constant can be referred to by
- its notation using :n:`@string` if such a notation exists).
-
-.. tacv:: simpl @qualid at {+ @natural}
- simpl @string at {+ @natural}
-
- This applies :tacn:`simpl` only to the :n:`{+ @natural}` applicative subterms whose
- head occurrence is :n:`@qualid` (or :n:`@string`).
-
-.. flag:: Debug RAKAM
-
- This flag makes :tacn:`cbn` print various debugging information.
- ``RAKAM`` is the Refolding Algebraic Krivine Abstract Machine.
-
-.. tacn:: unfold @qualid
- :name: unfold
-
- This tactic applies to any goal. The argument qualid must denote a
- defined transparent constant or local definition (see
- :ref:`gallina-definitions` and
- :ref:`vernac-controlling-the-reduction-strategies`). The tactic
- :tacn:`unfold` applies the :math:`\delta` rule to each occurrence
- of the constant to which :n:`@qualid` refers in the current goal
- and then replaces it with its :math:`\beta\iota\zeta`-normal form.
- Use the general reduction tactics if you want to avoid this final
- reduction, for instance :n:`cbv delta [@qualid]`.
-
- .. exn:: Cannot coerce @qualid to an evaluable reference.
-
- This error is frequent when trying to unfold something that has
- defined as an inductive type (or constructor) and not as a
- definition.
-
- .. example::
-
- .. coqtop:: abort all fail
-
- Goal 0 <= 1.
- unfold le.
-
- This error can also be raised if you are trying to unfold
- something that has been marked as opaque.
-
- .. example::
-
- .. coqtop:: abort all fail
-
- Opaque Nat.add.
- Goal 1 + 0 = 1.
- unfold Nat.add.
-
- .. tacv:: unfold @qualid in @goal_occurrences
-
- Replaces :n:`@qualid` in hypothesis (or hypotheses) designated
- by :token:`goal_occurrences` with its definition and replaces
- the hypothesis with its :math:`\beta`:math:`\iota` normal form.
-
- .. tacv:: unfold {+, @qualid}
-
- Replaces :n:`{+, @qualid}` with their definitions and replaces
- the current goal with its :math:`\beta`:math:`\iota` normal
- form.
-
- .. tacv:: unfold {+, @qualid at @occurrences }
-
- The list :token:`occurrences` specify the occurrences of
- :n:`@qualid` to be unfolded. Occurrences are located from left
- to right.
-
- .. exn:: Bad occurrence number of @qualid.
- :undocumented:
-
- .. exn:: @qualid does not occur.
- :undocumented:
-
- .. tacv:: unfold @string
-
- If :n:`@string` denotes the discriminating symbol of a notation
- (e.g. "+") or an expression defining a notation (e.g. `"_ +
- _"`), and this notation denotes an application whose head symbol
- is an unfoldable constant, then the tactic unfolds it.
-
- .. tacv:: unfold @string%@ident
-
- This is variant of :n:`unfold @string` where :n:`@string` gets
- its interpretation from the scope bound to the delimiting key
- :token:`ident` instead of its default interpretation (see
- :ref:`Localinterpretationrulesfornotations`).
-
- .. tacv:: unfold {+, {| @qualid | @string{? %@ident } } {? at @occurrences } } {? in @goal_occurrences }
-
- This is the most general form.
-
-.. tacn:: fold @term
- :name: fold
-
- This tactic applies to any goal. The term :n:`@term` is reduced using the
- :tacn:`red` tactic. Every occurrence of the resulting :n:`@term` in the goal is
- then replaced by :n:`@term`. This tactic is particularly useful when a fixpoint
- definition has been wrongfully unfolded, making the goal very hard to read.
- On the other hand, when an unfolded function applied to its argument has been
- reduced, the :tacn:`fold` tactic won't do anything.
-
- .. example::
-
- .. coqtop:: all abort
-
- Goal ~0=0.
- unfold not.
- Fail progress fold not.
- pattern (0 = 0).
- fold not.
-
- .. tacv:: fold {+ @term}
-
- Equivalent to :n:`fold @term ; ... ; fold @term`.
-
-.. tacn:: pattern @term
- :name: pattern
-
- This command applies to any goal. The argument :n:`@term` must be a free
- subterm of the current goal. The command pattern performs :math:`\beta`-expansion
- (the inverse of :math:`\beta`-reduction) of the current goal (say :g:`T`) by
-
- + replacing all occurrences of :n:`@term` in :g:`T` with a fresh variable
- + abstracting this variable
- + applying the abstracted goal to :n:`@term`
-
- For instance, if the current goal :g:`T` is expressible as
- :math:`\varphi`:g:`(t)` where the notation captures all the instances of :g:`t`
- in :math:`\varphi`:g:`(t)`, then :n:`pattern t` transforms it into
- :g:`(fun x:A =>` :math:`\varphi`:g:`(x)) t`. This tactic can be used, for
- instance, when the tactic ``apply`` fails on matching.
-
-.. tacv:: pattern @term at {+ @natural}
-
- Only the occurrences :n:`{+ @natural}` of :n:`@term` are considered for
- :math:`\beta`-expansion. Occurrences are located from left to right.
-
-.. tacv:: pattern @term at - {+ @natural}
-
- All occurrences except the occurrences of indexes :n:`{+ @natural }`
- of :n:`@term` are considered for :math:`\beta`-expansion. Occurrences are located from
- left to right.
-
-.. tacv:: pattern {+, @term}
-
- Starting from a goal :math:`\varphi`:g:`(t`:sub:`1` :g:`... t`:sub:`m`:g:`)`,
- the tactic :n:`pattern t`:sub:`1`:n:`, ..., t`:sub:`m` generates the
- equivalent goal
- :g:`(fun (x`:sub:`1`:g:`:A`:sub:`1`:g:`) ... (x`:sub:`m` :g:`:A`:sub:`m` :g:`) =>`:math:`\varphi`:g:`(x`:sub:`1` :g:`... x`:sub:`m` :g:`)) t`:sub:`1` :g:`... t`:sub:`m`.
- If :g:`t`:sub:`i` occurs in one of the generated types :g:`A`:sub:`j` these
- occurrences will also be considered and possibly abstracted.
-
-.. tacv:: pattern {+, @term at {+ @natural}}
-
- This behaves as above but processing only the occurrences :n:`{+ @natural}` of
- :n:`@term` starting from :n:`@term`.
-
-.. tacv:: pattern {+, @term {? at {? -} {+, @natural}}}
-
- This is the most general syntax that combines the different variants.
-
-.. tacn:: with_strategy @strategy_level_or_var [ {+ @reference } ] @ltac_expr3
- :name: with_strategy
-
- Executes :token:`ltac_expr3`, applying the alternate unfolding
- behavior that the :cmd:`Strategy` command controls, but only for
- :token:`ltac_expr3`. This can be useful for guarding calls to
- reduction in tactic automation to ensure that certain constants are
- never unfolded by tactics like :tacn:`simpl` and :tacn:`cbn` or to
- ensure that unfolding does not fail.
-
- .. example::
-
- .. coqtop:: all reset abort
-
- Opaque id.
- Goal id 10 = 10.
- Fail unfold id.
- with_strategy transparent [id] unfold id.
-
- .. warning::
-
- Use this tactic with care, as effects do not persist past the
- end of the proof script. Notably, this fine-tuning of the
- conversion strategy is not in effect during :cmd:`Qed` nor
- :cmd:`Defined`, so this tactic is most useful either in
- combination with :tacn:`abstract`, which will check the proof
- early while the fine-tuning is still in effect, or to guard
- calls to conversion in tactic automation to ensure that, e.g.,
- :tacn:`unfold` does not fail just because the user made a
- constant :cmd:`Opaque`.
-
- This can be illustrated with the following example involving the
- factorial function.
-
- .. coqtop:: in reset
-
- Fixpoint fact (n : nat) : nat :=
- match n with
- | 0 => 1
- | S n' => n * fact n'
- end.
-
- Suppose now that, for whatever reason, we want in general to
- unfold the :g:`id` function very late during conversion:
-
- .. coqtop:: in
-
- Strategy 1000 [id].
-
- If we try to prove :g:`id (fact n) = fact n` by
- :tacn:`reflexivity`, it will now take time proportional to
- :math:`n!`, because |Coq| will keep unfolding :g:`fact` and
- :g:`*` and :g:`+` before it unfolds :g:`id`, resulting in a full
- computation of :g:`fact n` (in unary, because we are using
- :g:`nat`), which takes time :math:`n!`. We can see this cross
- the relevant threshold at around :math:`n = 9`:
-
- .. coqtop:: all abort
-
- Goal True.
- Time assert (id (fact 8) = fact 8) by reflexivity.
- Time assert (id (fact 9) = fact 9) by reflexivity.
-
- Note that behavior will be the same if you mark :g:`id` as
- :g:`Opaque` because while most reduction tactics refuse to
- unfold :g:`Opaque` constants, conversion treats :g:`Opaque` as
- merely a hint to unfold this constant last.
-
- We can get around this issue by using :tacn:`with_strategy`:
-
- .. coqtop:: all
-
- Goal True.
- Fail Timeout 1 assert (id (fact 100) = fact 100) by reflexivity.
- Time assert (id (fact 100) = fact 100) by with_strategy -1 [id] reflexivity.
-
- However, when we go to close the proof, we will run into
- trouble, because the reduction strategy changes are local to the
- tactic passed to :tacn:`with_strategy`.
-
- .. coqtop:: all abort fail
-
- exact I.
- Timeout 1 Defined.
-
- We can fix this issue by using :tacn:`abstract`:
-
- .. coqtop:: all
-
- Goal True.
- Time assert (id (fact 100) = fact 100) by with_strategy -1 [id] abstract reflexivity.
- exact I.
- Time Defined.
-
- On small examples this sort of behavior doesn't matter, but
- because |Coq| is a super-linear performance domain in so many
- places, unless great care is taken, tactic automation using
- :tacn:`with_strategy` may not be robustly performant when
- scaling the size of the input.
-
- .. warning::
-
- In much the same way this tactic does not play well with
- :cmd:`Qed` and :cmd:`Defined` without using :tacn:`abstract` as
- an intermediary, this tactic does not play well with ``coqchk``,
- even when used with :tacn:`abstract`, due to the inability of
- tactics to persist information about conversion hints in the
- proof term. See `#12200
- <https://github.com/coq/coq/issues/12200>`_ for more details.
-
-Conversion tactics applied to hypotheses
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. tacn:: @tactic in {+, @ident}
-
- Applies :token:`tactic` (any of the conversion tactics listed in this
- section) to the hypotheses :n:`{+ @ident}`.
-
- If :token:`ident` is a local definition, then :token:`ident` can be replaced by
- :n:`type of @ident` to address not the body but the type of the local
- definition.
-
- Example: :n:`unfold not in (type of H1) (type of H3)`.
-
-.. exn:: No such hypothesis: @ident.
- :undocumented:
-
-
-.. _automation:
-
-Automation
-----------
-
-.. tacn:: auto
- :name: auto
-
- This tactic implements a Prolog-like resolution procedure to solve the
- current goal. It first tries to solve the goal using the :tacn:`assumption`
- tactic, then it reduces the goal to an atomic one using :tacn:`intros` and
- introduces the newly generated hypotheses as hints. Then it looks at
- the list of tactics associated to the head symbol of the goal and
- tries to apply one of them (starting from the tactics with lower
- cost). This process is recursively applied to the generated subgoals.
-
- By default, :tacn:`auto` only uses the hypotheses of the current goal and
- the hints of the database named ``core``.
-
- .. warning::
-
- :tacn:`auto` uses a weaker version of :tacn:`apply` that is closer to
- :tacn:`simple apply` so it is expected that sometimes :tacn:`auto` will
- fail even if applying manually one of the hints would succeed.
-
- .. tacv:: auto @natural
-
- Forces the search depth to be :token:`natural`. The maximal search depth
- is 5 by default.
-
- .. tacv:: auto with {+ @ident}
-
- Uses the hint databases :n:`{+ @ident}` in addition to the database ``core``.
-
- .. note::
-
- Use the fake database `nocore` if you want to *not* use the `core`
- database.
-
- .. tacv:: auto with *
-
- Uses all existing hint databases. Using this variant is highly discouraged
- in finished scripts since it is both slower and less robust than the variant
- where the required databases are explicitly listed.
-
- .. seealso::
- :ref:`The Hints Databases for auto and eauto <thehintsdatabasesforautoandeauto>` for the list of
- pre-defined databases and the way to create or extend a database.
-
- .. tacv:: auto using {+ @qualid__i} {? with {+ @ident } }
-
- Uses lemmas :n:`@qualid__i` in addition to hints. If :n:`@qualid` is an
- inductive type, it is the collection of its constructors which are added
- as hints.
-
- .. note::
-
- The hints passed through the `using` clause are used in the same
- way as if they were passed through a hint database. Consequently,
- they use a weaker version of :tacn:`apply` and :n:`auto using @qualid`
- may fail where :n:`apply @qualid` succeeds.
-
- Given that this can be seen as counter-intuitive, it could be useful
- to have an option to use full-blown :tacn:`apply` for lemmas passed
- through the `using` clause. Contributions welcome!
-
- .. tacv:: info_auto
-
- Behaves like :tacn:`auto` but shows the tactics it uses to solve the goal. This
- variant is very useful for getting a better understanding of automation, or
- to know what lemmas/assumptions were used.
-
- .. tacv:: debug auto
- :name: debug auto
-
- Behaves like :tacn:`auto` but shows the tactics it tries to solve the goal,
- including failing paths.
-
- .. tacv:: {? info_}auto {? @natural} {? using {+ @qualid}} {? with {+ @ident}}
-
- This is the most general form, combining the various options.
-
-.. tacv:: trivial
- :name: trivial
-
- This tactic is a restriction of :tacn:`auto` that is not recursive
- and tries only hints that cost `0`. Typically it solves trivial
- equalities like :g:`X=X`.
-
- .. tacv:: trivial with {+ @ident}
- trivial with *
- trivial using {+ @qualid}
- debug trivial
- info_trivial
- {? info_}trivial {? using {+ @qualid}} {? with {+ @ident}}
- :name: _; _; _; debug trivial; info_trivial; _
- :undocumented:
-
-.. note::
- :tacn:`auto` and :tacn:`trivial` either solve completely the goal or
- else succeed without changing the goal. Use :g:`solve [ auto ]` and
- :g:`solve [ trivial ]` if you would prefer these tactics to fail when
- they do not manage to solve the goal.
-
-.. flag:: Info Auto
- Debug Auto
- Info Trivial
- Debug Trivial
-
- These flags enable printing of informative or debug information for
- the :tacn:`auto` and :tacn:`trivial` tactics.
-
-.. tacn:: eauto
- :name: eauto
-
- This tactic generalizes :tacn:`auto`. While :tacn:`auto` does not try
- resolution hints which would leave existential variables in the goal,
- :tacn:`eauto` does try them (informally speaking, it internally uses a tactic
- close to :tacn:`simple eapply` instead of a tactic close to :tacn:`simple apply`
- in the case of :tacn:`auto`). As a consequence, :tacn:`eauto`
- can solve such a goal:
-
- .. example::
-
- .. coqtop:: all
-
- Hint Resolve ex_intro : core.
- Goal forall P:nat -> Prop, P 0 -> exists n, P n.
- eauto.
-
- Note that ``ex_intro`` should be declared as a hint.
-
-
- .. tacv:: {? info_}eauto {? @natural} {? using {+ @qualid}} {? with {+ @ident}}
-
- The various options for :tacn:`eauto` are the same as for :tacn:`auto`.
-
- :tacn:`eauto` also obeys the following flags:
-
- .. flag:: Info Eauto
- Debug Eauto
- :undocumented:
-
- .. seealso:: :ref:`The Hints Databases for auto and eauto <thehintsdatabasesforautoandeauto>`
-
-
-.. tacn:: autounfold with {+ @ident}
- :name: autounfold
-
- This tactic unfolds constants that were declared through a :cmd:`Hint Unfold`
- in the given databases.
-
-.. tacv:: autounfold with {+ @ident} in @goal_occurrences
-
- Performs the unfolding in the given clause (:token:`goal_occurrences`).
-
-.. tacv:: autounfold with *
-
- Uses the unfold hints declared in all the hint databases.
-
-.. tacn:: autorewrite with {+ @ident}
- :name: autorewrite
-
- This tactic carries out rewritings according to the rewriting rule
- bases :n:`{+ @ident}`.
-
- Each rewriting rule from the base :n:`@ident` is applied to the main subgoal until
- it fails. Once all the rules have been processed, if the main subgoal has
- progressed (e.g., if it is distinct from the initial main goal) then the rules
- of this base are processed again. If the main subgoal has not progressed then
- the next base is processed. For the bases, the behavior is exactly similar to
- the processing of the rewriting rules.
-
- The rewriting rule bases are built with the :cmd:`Hint Rewrite`
- command.
-
-.. warning::
-
- This tactic may loop if you build non terminating rewriting systems.
-
-.. tacv:: autorewrite with {+ @ident} using @tactic
-
- Performs, in the same way, all the rewritings of the bases :n:`{+ @ident}`
- applying tactic to the main subgoal after each rewriting step.
-
-.. tacv:: autorewrite with {+ @ident} in @qualid
-
- Performs all the rewritings in hypothesis :n:`@qualid`.
-
-.. tacv:: autorewrite with {+ @ident} in @qualid using @tactic
-
- Performs all the rewritings in hypothesis :n:`@qualid` applying :n:`@tactic`
- to the main subgoal after each rewriting step.
-
-.. tacv:: autorewrite with {+ @ident} in @goal_occurrences
-
- Performs all the rewriting in the clause :n:`@goal_occurrences`.
-
-.. seealso::
-
- :ref:`Hint-Rewrite <hintrewrite>` for feeding the database of lemmas used by
- :tacn:`autorewrite` and :tacn:`autorewrite` for examples showing the use of this tactic.
-
-.. tacn:: easy
- :name: easy
-
- This tactic tries to solve the current goal by a number of standard closing steps.
- In particular, it tries to close the current goal using the closing tactics
- :tacn:`trivial`, :tacn:`reflexivity`, :tacn:`symmetry`, :tacn:`contradiction`
- and :tacn:`inversion` of hypothesis.
- If this fails, it tries introducing variables and splitting and-hypotheses,
- using the closing tactics afterwards, and splitting the goal using
- :tacn:`split` and recursing.
-
- This tactic solves goals that belong to many common classes; in particular, many cases of
- unsatisfiable hypotheses, and simple equality goals are usually solved by this tactic.
-
-.. tacv:: now @tactic
- :name: now
-
- Run :n:`@tactic` followed by :tacn:`easy`. This is a notation for :n:`@tactic; easy`.
-
-Controlling automation
---------------------------
-
-.. _thehintsdatabasesforautoandeauto:
-
-The hints databases for auto and eauto
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The hints for :tacn:`auto` and :tacn:`eauto` are stored in databases. Each database
-maps head symbols to a list of hints.
-
-.. cmd:: Print Hint @ident
-
- Use this command
- to display the hints associated to the head symbol :n:`@ident`
- (see :ref:`Print Hint <printhint>`). Each hint has a cost that is a nonnegative
- integer, and an optional pattern. The hints with lower cost are tried first. A
- hint is tried by :tacn:`auto` when the conclusion of the current goal matches its
- pattern or when it has no pattern.
-
-Creating Hint databases
-```````````````````````
-
-One can optionally declare a hint database using the command
-:cmd:`Create HintDb`. If a hint is added to an unknown database, it will be
-automatically created.
-
-.. cmd:: Create HintDb @ident {? discriminated}
-
- This command creates a new database named :n:`@ident`. The database is
- implemented by a Discrimination Tree (DT) that serves as an index of
- all the lemmas. The DT can use transparency information to decide if a
- constant should be indexed or not
- (c.f. :ref:`The hints databases for auto and eauto <thehintsdatabasesforautoandeauto>`),
- making the retrieval more efficient. The legacy implementation (the default one
- for new databases) uses the DT only on goals without existentials (i.e., :tacn:`auto`
- goals), for non-Immediate hints and does not make use of transparency
- hints, putting more work on the unification that is run after
- retrieval (it keeps a list of the lemmas in case the DT is not used).
- The new implementation enabled by the discriminated option makes use
- of DTs in all cases and takes transparency information into account.
- However, the order in which hints are retrieved from the DT may differ
- from the order in which they were inserted, making this implementation
- observationally different from the legacy one.
-
-.. cmd:: Hint @hint_definition : {+ @ident}
-
- The general command to add a hint to some databases :n:`{+ @ident}`.
-
- This command supports the :attr:`local`, :attr:`global` and :attr:`export`
- locality attributes. When no locality is explictly given, the
- command is :attr:`local` inside a section and :attr:`global` otherwise.
-
- + :attr:`local` hints are never visible from other modules, even if they
- require or import the current module. Inside a section, the :attr:`local`
- attribute is useless since hints do not survive anyway to the closure of
- sections.
-
- + :attr:`export` are visible from other modules when they import the current
- module. Requiring it is not enough. This attribute is only effective for
- the :cmd:`Hint Resolve`, :cmd:`Hint Immediate`, :cmd:`Hint Unfold` and
- :cmd:`Hint Extern` variants of the command.
-
- + :attr:`global` hints are made available by merely requiring the current
- module.
-
- The various possible :production:`hint_definition`\s are given below.
-
- .. cmdv:: Hint @hint_definition
-
- No database name is given: the hint is registered in the ``core`` database.
-
- .. deprecated:: 8.10
-
- .. cmdv:: Hint Resolve @qualid {? | {? @natural} {? @pattern}} : @ident
- :name: Hint Resolve
-
- This command adds :n:`simple apply @qualid` to the hint list with the head
- symbol of the type of :n:`@qualid`. The cost of that hint is the number of
- subgoals generated by :n:`simple apply @qualid` or :n:`@natural` if specified. The
- associated :n:`@pattern` is inferred from the conclusion of the type of
- :n:`@qualid` or the given :n:`@pattern` if specified. In case the inferred type
- of :n:`@qualid` does not start with a product the tactic added in the hint list
- is :n:`exact @qualid`. In case this type can however be reduced to a type
- starting with a product, the tactic :n:`simple apply @qualid` is also stored in
- the hints list. If the inferred type of :n:`@qualid` contains a dependent
- quantification on a variable which occurs only in the premisses of the type
- and not in its conclusion, no instance could be inferred for the variable by
- unification with the goal. In this case, the hint is added to the hint list
- of :tacn:`eauto` instead of the hint list of auto and a warning is printed. A
- typical example of a hint that is used only by :tacn:`eauto` is a transitivity
- lemma.
-
- .. exn:: @qualid cannot be used as a hint
-
- The head symbol of the type of :n:`@qualid` is a bound variable
- such that this tactic cannot be associated to a constant.
-
- .. cmdv:: Hint Resolve {+ @qualid} : @ident
-
- Adds each :n:`Hint Resolve @qualid`.
-
- .. cmdv:: Hint Resolve -> @qualid : @ident
-
- Adds the left-to-right implication of an equivalence as a hint (informally
- the hint will be used as :n:`apply <- @qualid`, although as mentioned
- before, the tactic actually used is a restricted version of
- :tacn:`apply`).
-
- .. cmdv:: Hint Resolve <- @qualid
-
- Adds the right-to-left implication of an equivalence as a hint.
-
- .. cmdv:: Hint Immediate @qualid : @ident
- :name: Hint Immediate
-
- This command adds :n:`simple apply @qualid; trivial` to the hint list associated
- with the head symbol of the type of :n:`@ident` in the given database. This
- tactic will fail if all the subgoals generated by :n:`simple apply @qualid` are
- not solved immediately by the :tacn:`trivial` tactic (which only tries tactics
- with cost 0).This command is useful for theorems such as the symmetry of
- equality or :g:`n+1=m+1 -> n=m` that we may like to introduce with a limited
- use in order to avoid useless proof-search. The cost of this tactic (which
- never generates subgoals) is always 1, so that it is not used by :tacn:`trivial`
- itself.
-
- .. exn:: @qualid cannot be used as a hint
- :undocumented:
-
- .. cmdv:: Hint Immediate {+ @qualid} : @ident
-
- Adds each :n:`Hint Immediate @qualid`.
-
- .. cmdv:: Hint Constructors @qualid : @ident
- :name: Hint Constructors
-
- If :token:`qualid` is an inductive type, this command adds all its constructors as
- hints of type ``Resolve``. Then, when the conclusion of current goal has the form
- :n:`(@qualid ...)`, :tacn:`auto` will try to apply each constructor.
-
- .. exn:: @qualid is not an inductive type
- :undocumented:
-
- .. cmdv:: Hint Constructors {+ @qualid} : @ident
-
- Extends the previous command for several inductive types.
-
- .. cmdv:: Hint Unfold @qualid : @ident
- :name: Hint Unfold
-
- This adds the tactic :n:`unfold @qualid` to the hint list that will only be
- used when the head constant of the goal is :token:`qualid`.
- Its cost is 4.
-
- .. cmdv:: Hint Unfold {+ @qualid}
-
- Extends the previous command for several defined constants.
-
- .. cmdv:: Hint Transparent {+ @qualid} : @ident
- Hint Opaque {+ @qualid} : @ident
- :name: Hint Transparent; Hint Opaque
-
- This adds transparency hints to the database, making :n:`@qualid`
- transparent or opaque constants during resolution. This information is used
- during unification of the goal with any lemma in the database and inside the
- discrimination network to relax or constrain it in the case of discriminated
- databases.
-
- .. cmdv:: Hint Variables {| Transparent | Opaque } : @ident
- Hint Constants {| Transparent | Opaque } : @ident
- :name: Hint Variables; Hint Constants
-
- This sets the transparency flag used during unification of
- hints in the database for all constants or all variables,
- overwriting the existing settings of opacity. It is advised
- to use this just after a :cmd:`Create HintDb` command.
-
- .. cmdv:: Hint Extern @natural {? @pattern} => @tactic : @ident
- :name: Hint Extern
-
- This hint type is to extend :tacn:`auto` with tactics other than :tacn:`apply` and
- :tacn:`unfold`. For that, we must specify a cost, an optional :n:`@pattern` and a
- :n:`@tactic` to execute.
-
- .. example::
-
- .. coqtop:: in
-
- Hint Extern 4 (~(_ = _)) => discriminate : core.
-
- Now, when the head of the goal is a disequality, ``auto`` will try
- discriminate if it does not manage to solve the goal with hints with a
- cost less than 4.
-
- One can even use some sub-patterns of the pattern in
- the tactic script. A sub-pattern is a question mark followed by an
- identifier, like ``?X1`` or ``?X2``. Here is an example:
-
- .. example::
-
- .. coqtop:: reset all
-
- Require Import List.
- Hint Extern 5 ({?X1 = ?X2} + {?X1 <> ?X2}) => generalize X1, X2; decide equality : eqdec.
- Goal forall a b:list (nat * nat), {a = b} + {a <> b}.
- Info 1 auto with eqdec.
-
- .. cmdv:: Hint Cut @regexp : @ident
- :name: Hint Cut
-
- .. warning::
-
- These hints currently only apply to typeclass proof search and the
- :tacn:`typeclasses eauto` tactic.
-
- This command can be used to cut the proof-search tree according to a regular
- expression matching paths to be cut. The grammar for regular expressions is
- the following. Beware, there is no operator precedence during parsing, one can
- check with :cmd:`Print HintDb` to verify the current cut expression:
-
- .. prodn::
- regexp ::= @ident (hint or instance identifier)
- | _ (any hint)
- | @regexp | @regexp (disjunction)
- | @regexp @regexp (sequence)
- | @regexp * (Kleene star)
- | emp (empty)
- | eps (epsilon)
- | ( @regexp )
-
- The `emp` regexp does not match any search path while `eps`
- matches the empty path. During proof search, the path of
- successive successful hints on a search branch is recorded, as a
- list of identifiers for the hints (note that :cmd:`Hint Extern`\’s do not have
- an associated identifier).
- Before applying any hint :n:`@ident` the current path `p` extended with
- :n:`@ident` is matched against the current cut expression `c` associated to
- the hint database. If matching succeeds, the hint is *not* applied. The
- semantics of :n:`Hint Cut @regexp` is to set the cut expression
- to :n:`c | regexp`, the initial cut expression being `emp`.
-
- .. cmdv:: Hint Mode @qualid {* {| + | ! | - } } : @ident
- :name: Hint Mode
-
- This sets an optional mode of use of the identifier :n:`@qualid`. When
- proof-search faces a goal that ends in an application of :n:`@qualid` to
- arguments :n:`@term ... @term`, the mode tells if the hints associated to
- :n:`@qualid` can be applied or not. A mode specification is a list of n ``+``,
- ``!`` or ``-`` items that specify if an argument of the identifier is to be
- treated as an input (``+``), if its head only is an input (``!``) or an output
- (``-``) of the identifier. For a mode to match a list of arguments, input
- terms and input heads *must not* contain existential variables or be
- existential variables respectively, while outputs can be any term. Multiple
- modes can be declared for a single identifier, in that case only one mode
- needs to match the arguments for the hints to be applied. The head of a term
- is understood here as the applicative head, or the match or projection
- scrutinee’s head, recursively, casts being ignored. :cmd:`Hint Mode` is
- especially useful for typeclasses, when one does not want to support default
- instances and avoid ambiguity in general. Setting a parameter of a class as an
- input forces proof-search to be driven by that index of the class, with ``!``
- giving more flexibility by allowing existentials to still appear deeper in the
- index but not at its head.
-
- .. note::
-
- + One can use a :cmd:`Hint Extern` with no pattern to do
- pattern matching on hypotheses using ``match goal with``
- inside the tactic.
-
- + If you want to add hints such as :cmd:`Hint Transparent`,
- :cmd:`Hint Cut`, or :cmd:`Hint Mode`, for typeclass
- resolution, do not forget to put them in the
- ``typeclass_instances`` hint database.
-
-
-Hint databases defined in the Coq standard library
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Several hint databases are defined in the Coq standard library. The
-actual content of a database is the collection of hints declared
-to belong to this database in each of the various modules currently
-loaded. Especially, requiring new modules may extend the database.
-At Coq startup, only the core database is nonempty and can be used.
-
-:core: This special database is automatically used by ``auto``, except when
- pseudo-database ``nocore`` is given to ``auto``. The core database
- contains only basic lemmas about negation, conjunction, and so on.
- Most of the hints in this database come from the Init and Logic directories.
-
-:arith: This database contains all lemmas about Peano’s arithmetic proved in the
- directories Init and Arith.
-
-:zarith: contains lemmas about binary signed integers from the
- directories theories/ZArith. The database also contains
- high-cost hints that call :tacn:`lia` on equations and
- inequalities in ``nat`` or ``Z``.
-
-:bool: contains lemmas about booleans, mostly from directory theories/Bool.
-
-:datatypes: is for lemmas about lists, streams and so on that are mainly proved
- in the Lists subdirectory.
-
-:sets: contains lemmas about sets and relations from the directories Sets and
- Relations.
-
-:typeclass_instances: contains all the typeclass instances declared in the
- environment, including those used for ``setoid_rewrite``,
- from the Classes directory.
-
-:fset: internal database for the implementation of the ``FSets`` library.
-
-:ordered_type: lemmas about ordered types (as defined in the legacy ``OrderedType`` module),
- mainly used in the ``FSets`` and ``FMaps`` libraries.
-
-You are advised not to put your own hints in the core database, but
-use one or several databases specific to your development.
-
-.. _removehints:
-
-.. cmd:: Remove Hints {+ @term} : {+ @ident}
-
- This command removes the hints associated to terms :n:`{+ @term}` in databases
- :n:`{+ @ident}`.
-
-.. _printhint:
-
-.. cmd:: Print Hint
-
- This command displays all hints that apply to the current goal. It
- fails if no proof is being edited, while the two variants can be used
- at every moment.
-
-**Variants:**
-
-
-.. cmd:: Print Hint @ident
-
- This command displays only tactics associated with :n:`@ident` in the hints
- list. This is independent of the goal being edited, so this command will not
- fail if no goal is being edited.
-
-.. cmd:: Print Hint *
-
- This command displays all declared hints.
-
-.. cmd:: Print HintDb @ident
-
- This command displays all hints from database :n:`@ident`.
-
-.. _hintrewrite:
-
-.. cmd:: Hint Rewrite {+ @term} : {+ @ident}
-
- This vernacular command adds the terms :n:`{+ @term}` (their types must be
- equalities) in the rewriting bases :n:`{+ @ident}` with the default orientation
- (left to right). Notice that the rewriting bases are distinct from the :tacn:`auto`
- hint bases and that :tacn:`auto` does not take them into account.
-
- This command is synchronous with the section mechanism (see :ref:`section-mechanism`):
- when closing a section, all aliases created by ``Hint Rewrite`` in that
- section are lost. Conversely, when loading a module, all ``Hint Rewrite``
- declarations at the global level of that module are loaded.
-
-**Variants:**
-
-.. cmd:: Hint Rewrite -> {+ @term} : {+ @ident}
-
- This is strictly equivalent to the command above (we only make explicit the
- orientation which otherwise defaults to ->).
-
-.. cmd:: Hint Rewrite <- {+ @term} : {+ @ident}
-
- Adds the rewriting rules :n:`{+ @term}` with a right-to-left orientation in
- the bases :n:`{+ @ident}`.
-
-.. cmd:: Hint Rewrite {+ @term} using @tactic : {+ @ident}
-
- When the rewriting rules :n:`{+ @term}` in :n:`{+ @ident}` will be used, the
- tactic ``tactic`` will be applied to the generated subgoals, the main subgoal
- excluded.
-
-.. cmd:: Print Rewrite HintDb @ident
-
- This command displays all rewrite hints contained in :n:`@ident`.
-
-Hint locality
-~~~~~~~~~~~~~
-
-Hints provided by the ``Hint`` commands are erased when closing a section.
-Conversely, all hints of a module ``A`` that are not defined inside a
-section (and not defined with option ``Local``) become available when the
-module ``A`` is required (using e.g. ``Require A.``).
-
-As of today, hints only have a binary behavior regarding locality, as
-described above: either they disappear at the end of a section scope,
-or they remain global forever. This causes a scalability issue,
-because hints coming from an unrelated part of the code may badly
-influence another development. It can be mitigated to some extent
-thanks to the :cmd:`Remove Hints` command,
-but this is a mere workaround and has some limitations (for instance, external
-hints cannot be removed).
-
-A proper way to fix this issue is to bind the hints to their module scope, as
-for most of the other objects Coq uses. Hints should only be made available when
-the module they are defined in is imported, not just required. It is very
-difficult to change the historical behavior, as it would break a lot of scripts.
-We propose a smooth transitional path by providing the :opt:`Loose Hint Behavior`
-option which accepts three flags allowing for a fine-grained handling of
-non-imported hints.
-
-.. opt:: Loose Hint Behavior {| "Lax" | "Warn" | "Strict" }
- :name: Loose Hint Behavior
-
- This option accepts three values, which control the behavior of hints w.r.t.
- :cmd:`Import`:
-
- - "Lax": this is the default, and corresponds to the historical behavior,
- that is, hints defined outside of a section have a global scope.
-
- - "Warn": outputs a warning when a non-imported hint is used. Note that this
- is an over-approximation, because a hint may be triggered by a run that
- will eventually fail and backtrack, resulting in the hint not being
- actually useful for the proof.
-
- - "Strict": changes the behavior of an unloaded hint to a immediate fail
- tactic, allowing to emulate an import-scoped hint mechanism.
-
-.. _tactics-implicit-automation:
-
-Setting implicit automation tactics
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. cmd:: Proof with @tactic
-
- This command may be used to start a proof. It defines a default tactic
- to be used each time a tactic command ``tactic``:sub:`1` is ended by ``...``.
- In this case the tactic command typed by the user is equivalent to
- ``tactic``:sub:`1` ``;tactic``.
-
- .. seealso:: :cmd:`Proof` in :ref:`proof-editing-mode`.
-
-
- .. cmdv:: Proof with @tactic using {+ @ident}
-
- Combines in a single line ``Proof with`` and ``Proof using``, see :ref:`proof-editing-mode`
-
- .. cmdv:: Proof using {+ @ident} with @tactic
-
- Combines in a single line ``Proof with`` and ``Proof using``, see :ref:`proof-editing-mode`
-
-.. _decisionprocedures:
-
-Decision procedures
--------------------
-
-.. tacn:: tauto
- :name: tauto
-
- This tactic implements a decision procedure for intuitionistic propositional
- calculus based on the contraction-free sequent calculi LJT* of Roy Dyckhoff
- :cite:`Dyc92`. Note that :tacn:`tauto` succeeds on any instance of an
- intuitionistic tautological proposition. :tacn:`tauto` unfolds negations and
- logical equivalence but does not unfold any other definition.
-
-.. example::
-
- The following goal can be proved by :tacn:`tauto` whereas :tacn:`auto` would
- fail:
-
- .. coqtop:: reset all
-
- Goal forall (x:nat) (P:nat -> Prop), x = 0 \/ P x -> x <> 0 -> P x.
- intros.
- tauto.
-
-Moreover, if it has nothing else to do, :tacn:`tauto` performs introductions.
-Therefore, the use of :tacn:`intros` in the previous proof is unnecessary.
-:tacn:`tauto` can for instance for:
-
-.. example::
-
- .. coqtop:: reset all
-
- Goal forall (A:Prop) (P:nat -> Prop), A \/ (forall x:nat, ~ A -> P x) -> forall x:nat, ~ A -> P x.
- tauto.
-
-.. note::
- In contrast, :tacn:`tauto` cannot solve the following goal
- :g:`Goal forall (A:Prop) (P:nat -> Prop), A \/ (forall x:nat, ~ A -> P x) ->`
- :g:`forall x:nat, ~ ~ (A \/ P x).`
- because :g:`(forall x:nat, ~ A -> P x)` cannot be treated as atomic and
- an instantiation of `x` is necessary.
-
-.. tacv:: dtauto
- :name: dtauto
-
- While :tacn:`tauto` recognizes inductively defined connectives isomorphic to
- the standard connectives ``and``, ``prod``, ``or``, ``sum``, ``False``,
- ``Empty_set``, ``unit``, ``True``, :tacn:`dtauto` also recognizes all inductive
- types with one constructor and no indices, i.e. record-style connectives.
-
-.. tacn:: intuition @tactic
- :name: intuition
-
- The tactic :tacn:`intuition` takes advantage of the search-tree built by the
- decision procedure involved in the tactic :tacn:`tauto`. It uses this
- information to generate a set of subgoals equivalent to the original one (but
- simpler than it) and applies the tactic :n:`@tactic` to them :cite:`Mun94`. If
- this tactic fails on some goals then :tacn:`intuition` fails. In fact,
- :tacn:`tauto` is simply :g:`intuition fail`.
-
- .. example::
-
- For instance, the tactic :g:`intuition auto` applied to the goal::
-
- (forall (x:nat), P x) /\ B -> (forall (y:nat), P y) /\ P O \/ B /\ P O
-
- internally replaces it by the equivalent one::
-
- (forall (x:nat), P x), B |- P O
-
- and then uses :tacn:`auto` which completes the proof.
-
-Originally due to César Muñoz, these tactics (:tacn:`tauto` and
-:tacn:`intuition`) have been completely re-engineered by David Delahaye using
-mainly the tactic language (see :ref:`ltac`). The code is
-now much shorter and a significant increase in performance has been noticed.
-The general behavior with respect to dependent types, unfolding and
-introductions has slightly changed to get clearer semantics. This may lead to
-some incompatibilities.
-
-.. tacv:: intuition
-
- Is equivalent to :g:`intuition auto with *`.
-
-.. tacv:: dintuition
- :name: dintuition
-
- While :tacn:`intuition` recognizes inductively defined connectives
- isomorphic to the standard connectives ``and``, ``prod``, ``or``, ``sum``, ``False``,
- ``Empty_set``, ``unit``, ``True``, :tacn:`dintuition` also recognizes all inductive
- types with one constructor and no indices, i.e. record-style connectives.
-
-.. flag:: Intuition Negation Unfolding
-
- Controls whether :tacn:`intuition` unfolds inner negations which do not need
- to be unfolded. This flag is on by default.
-
-.. tacn:: rtauto
- :name: rtauto
-
- The :tacn:`rtauto` tactic solves propositional tautologies similarly to what
- :tacn:`tauto` does. The main difference is that the proof term is built using a
- reflection scheme applied to a sequent calculus proof of the goal. The search
- procedure is also implemented using a different technique.
-
- Users should be aware that this difference may result in faster proof-search
- but slower proof-checking, and :tacn:`rtauto` might not solve goals that
- :tacn:`tauto` would be able to solve (e.g. goals involving universal
- quantifiers).
-
- Note that this tactic is only available after a ``Require Import Rtauto``.
-
-.. tacn:: firstorder
- :name: firstorder
-
- The tactic :tacn:`firstorder` is an experimental extension of :tacn:`tauto` to
- first- order reasoning, written by Pierre Corbineau. It is not restricted to
- usual logical connectives but instead may reason about any first-order class
- inductive definition.
-
-.. opt:: Firstorder Solver @tactic
- :name: Firstorder Solver
-
- The default tactic used by :tacn:`firstorder` when no rule applies is
- :g:`auto with core`, it can be reset locally or globally using this option.
-
- .. cmd:: Print Firstorder Solver
-
- Prints the default tactic used by :tacn:`firstorder` when no rule applies.
-
-.. tacv:: firstorder @tactic
-
- Tries to solve the goal with :n:`@tactic` when no logical rule may apply.
-
-.. tacv:: firstorder using {+ @qualid}
-
- .. deprecated:: 8.3
-
- Use the syntax below instead (with commas).
-
-.. tacv:: firstorder using {+, @qualid}
-
- Adds lemmas :n:`{+, @qualid}` to the proof-search environment. If :n:`@qualid`
- refers to an inductive type, it is the collection of its constructors which are
- added to the proof-search environment.
-
-.. tacv:: firstorder with {+ @ident}
-
- Adds lemmas from :tacn:`auto` hint bases :n:`{+ @ident}` to the proof-search
- environment.
-
-.. tacv:: firstorder @tactic using {+, @qualid} with {+ @ident}
-
- This combines the effects of the different variants of :tacn:`firstorder`.
-
-.. opt:: Firstorder Depth @natural
- :name: Firstorder Depth
-
- This option controls the proof-search depth bound.
-
-.. tacn:: congruence
- :name: congruence
-
- The tactic :tacn:`congruence`, by Pierre Corbineau, implements the standard
- Nelson and Oppen congruence closure algorithm, which is a decision procedure
- for ground equalities with uninterpreted symbols. It also includes
- constructor theory (see :tacn:`injection` and :tacn:`discriminate`). If the goal
- is a non-quantified equality, congruence tries to prove it with non-quantified
- equalities in the context. Otherwise it tries to infer a discriminable equality
- from those in the context. Alternatively, congruence tries to prove that a
- hypothesis is equal to the goal or to the negation of another hypothesis.
-
- :tacn:`congruence` is also able to take advantage of hypotheses stating
- quantified equalities, but you have to provide a bound for the number of extra
- equalities generated that way. Please note that one of the sides of the
- 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.
- intros.
- congruence.
- Qed.
-
- Theorem inj (A:Type) (f:A -> A * A) (a c d: A) : f = pair a -> Some (f c) = Some (f d) -> c=d.
- intros.
- congruence.
- Qed.
-
-.. tacv:: congruence @natural
-
- Tries to add at most :token:`natural` instances of hypotheses stating quantified equalities
- to the problem in order to solve it. A bigger value of :token:`natural` does not make
- success slower, only failure. You might consider adding some lemmas as
- hypotheses using assert in order for :tacn:`congruence` to use them.
-
-.. tacv:: congruence with {+ @term}
- :name: congruence with
-
- Adds :n:`{+ @term}` to the pool of terms used by :tacn:`congruence`. This helps
- in case you have partially applied constructors in your goal.
-
-.. exn:: I don’t know how to handle dependent equality.
-
- The decision procedure managed to find a proof of the goal or of a
- 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 {+ @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
- appropriate type will allow the tactic to successfully solve the goal. Those
- additional arguments can be given to congruence by filling in the holes in the
- terms given in the error message, using the :tacn:`congruence with` variant described above.
-
-.. flag:: Congruence Verbose
-
- This flag makes :tacn:`congruence` print debug information.
-
Checking properties of terms
----------------------------
@@ -4600,13 +2840,13 @@ symbol :g:`=`.
:n:`simplify_eq @ident` where :n:`@ident` is the identifier for the last
introduced hypothesis.
-.. tacv:: simplify_eq @term with @bindings_list
+.. tacv:: simplify_eq @term with @bindings
This does the same as :n:`simplify_eq @term` but using the given bindings to
instantiate parameters or hypotheses of :n:`@term`.
.. tacv:: esimplify_eq @natural
- esimplify_eq @term {? with @bindings_list}
+ esimplify_eq @term {? with @bindings}
:name: esimplify_eq; _
This works the same as :tacn:`simplify_eq` but if the type of :n:`@term`, or the
@@ -4653,189 +2893,6 @@ using the ``Require Import`` command.
Use :tacn:`classical_right` to prove the right part of the disjunction with
the assumption that the negation of left part holds.
-.. _tactics-automating:
-
-Automating
-------------
-
-
-.. tacn:: btauto
- :name: btauto
-
- The tactic :tacn:`btauto` implements a reflexive solver for boolean
- tautologies. It solves goals of the form :g:`t = u` where `t` and `u` are
- constructed over the following grammar:
-
- .. prodn::
- btauto_term ::= @ident
- | true
- | false
- | orb @btauto_term @btauto_term
- | andb @btauto_term @btauto_term
- | xorb @btauto_term @btauto_term
- | negb @btauto_term
- | if @btauto_term then @btauto_term else @btauto_term
-
- Whenever the formula supplied is not a tautology, it also provides a
- counter-example.
-
- Internally, it uses a system very similar to the one of the ring
- tactic.
-
- Note that this tactic is only available after a ``Require Import Btauto``.
-
- .. exn:: Cannot recognize a boolean equality.
-
- The goal is not of the form :g:`t = u`. Especially note that :tacn:`btauto`
- doesn't introduce variables into the context on its own.
-
-.. tacv:: field
- field_simplify {* @term}
- field_simplify_eq
-
- The field tactic is built on the same ideas as ring: this is a
- reflexive tactic that solves or simplifies equations in a field
- structure. The main idea is to reduce a field expression (which is an
- extension of ring expressions with the inverse and division
- operations) to a fraction made of two polynomial expressions.
-
- Tactic :n:`field` is used to solve subgoals, whereas :n:`field_simplify {+ @term}`
- replaces the provided terms by their reduced fraction.
- :n:`field_simplify_eq` applies when the conclusion is an equation: it
- simplifies both hand sides and multiplies so as to cancel
- denominators. So it produces an equation without division nor inverse.
-
- All of these 3 tactics may generate a subgoal in order to prove that
- denominators are different from zero.
-
- See :ref:`Theringandfieldtacticfamilies` for more information on the tactic and how to
- declare new field structures. All declared field structures can be
- printed with the Print Fields command.
-
-.. example::
-
- .. coqtop:: reset all
-
- Require Import Reals.
- Goal forall x y:R,
- (x * y > 0)%R ->
- (x * (1 / x + x / (x + y)))%R =
- ((- 1 / y) * y * (- x * (x / (x + y)) - 1))%R.
-
- intros; field.
-
-.. seealso::
-
- File plugins/ring/RealField.v for an example of instantiation,
- theory theories/Reals for many examples of use of field.
-
-Non-logical tactics
-------------------------
-
-
-.. tacn:: cycle @integer
- :name: cycle
-
- Reorders the selected goals so that the first :n:`@integer` goals appear after the
- other selected goals.
- If :n:`@integer` is negative, it puts the last :n:`@integer` goals at the
- beginning of the list.
- The tactic is only useful with a goal selector, most commonly `all:`.
- Note that other selectors reorder goals; `1,3: cycle 1` is not equivalent
- to `all: cycle 1`. See :tacn:`… : … (goal selector)`.
-
-.. example::
-
- .. coqtop:: none reset
-
- Parameter P : nat -> Prop.
-
- .. coqtop:: all abort
-
- Goal P 1 /\ P 2 /\ P 3 /\ P 4 /\ P 5.
- repeat split.
- all: cycle 2.
- all: cycle -3.
-
-.. tacn:: swap @integer @integer
- :name: swap
-
- Exchanges the position of the specified goals.
- Negative values for :n:`@integer` indicate counting goals
- backward from the end of the list of selected goals. Goals are indexed from 1.
- The tactic is only useful with a goal selector, most commonly `all:`.
- Note that other selectors reorder goals; `1,3: swap 1 3` is not equivalent
- to `all: swap 1 3`. See :tacn:`… : … (goal selector)`.
-
-.. example::
-
- .. coqtop:: all abort
-
- Goal P 1 /\ P 2 /\ P 3 /\ P 4 /\ P 5.
- repeat split.
- all: swap 1 3.
- all: swap 1 -1.
-
-.. tacn:: revgoals
- :name: revgoals
-
- Reverses the order of the selected goals. The tactic is only useful with a goal
- selector, most commonly `all :`. Note that other selectors reorder goals;
- `1,3: revgoals` is not equivalent to `all: revgoals`. See :tacn:`… : … (goal selector)`.
-
- .. example::
-
- .. coqtop:: all abort
-
- Goal P 1 /\ P 2 /\ P 3 /\ P 4 /\ P 5.
- repeat split.
- all: revgoals.
-
-.. tacn:: shelve
- :name: shelve
-
- This tactic moves all goals under focus to a shelf. While on the
- shelf, goals will not be focused on. They can be solved by
- unification, or they can be called back into focus with the command
- :cmd:`Unshelve`.
-
- .. tacv:: shelve_unifiable
- :name: shelve_unifiable
-
- Shelves only the goals under focus that are mentioned in other goals.
- Goals that appear in the type of other goals can be solved by unification.
-
- .. example::
-
- .. coqtop:: all abort
-
- Goal exists n, n=0.
- refine (ex_intro _ _ _).
- all: shelve_unifiable.
- reflexivity.
-
-.. cmd:: Unshelve
-
- This command moves all the goals on the shelf (see :tacn:`shelve`)
- from the shelf into focus, by appending them to the end of the current
- list of focused goals.
-
-.. tacn:: unshelve @tactic
- :name: unshelve
-
- Performs :n:`@tactic`, then unshelves existential variables added to the
- shelf by the execution of :n:`@tactic`, prepending them to the current goal.
-
-.. tacn:: give_up
- :name: give_up
-
- This tactic removes the focused goals from the proof. They are not
- solved, and cannot be solved later in the proof. As the goals are not
- solved, the proof cannot be closed.
-
- The ``give_up`` tactic can be used while editing a proof, to choose to
- write the proof script in a non-sequential order.
-
Delaying solving unification constraints
----------------------------------------
@@ -4855,14 +2912,14 @@ Proof maintenance
*Experimental.* Many tactics, such as :tacn:`intros`, can automatically generate names, such
as "H0" or "H1" for a new hypothesis introduced from a goal. Subsequent proof steps
-may explicitly refer to these names. However, future versions of Coq may not assign
+may explicitly refer to these names. However, future versions of |Coq| may not assign
names exactly the same way, which could cause the proof to fail because the
new names don't match the explicit references in the proof.
The following "Mangle Names" settings let users find all the
places where proofs rely on automatically generated names, which can
then be named explicitly to avoid any incompatibility. These
-settings cause Coq to generate different names, producing errors for
+settings cause |Coq| to generate different names, producing errors for
references to automatically generated names.
.. flag:: Mangle Names
@@ -4884,7 +2941,7 @@ Performance-oriented tactic variants
For advanced usage. Similar to :tacn:`change` :n:`@term`, but as an optimization,
it skips checking that :n:`@term` is convertible to the goal.
- Recall that the Coq kernel typechecks proofs again when they are concluded to
+ Recall that the |Coq| kernel typechecks proofs again when they are concluded to
ensure safety. Hence, using :tacn:`change` checks convertibility twice
overall, while :tacn:`change_no_check` can produce ill-typed terms,
but checks convertibility only once.
diff --git a/doc/sphinx/proof-engine/vernacular-commands.rst b/doc/sphinx/proof-engine/vernacular-commands.rst
index 6c07253bce..dd0b12f8ec 100644
--- a/doc/sphinx/proof-engine/vernacular-commands.rst
+++ b/doc/sphinx/proof-engine/vernacular-commands.rst
@@ -637,10 +637,10 @@ file is a particular case of a module called a *library file*.
.. cmd:: Declare ML Module {+ @string }
- This commands dynamically loads OCaml compiled code from
+ This commands dynamically loads |OCaml| compiled code from
a :n:`.mllib` file.
It is used to load plugins dynamically. The
- files must be accessible in the current OCaml loadpath (see the
+ files must be accessible in the current |OCaml| loadpath (see the
command :cmd:`Add ML Path`). The :n:`.mllib` suffix may be omitted.
This command is reserved for plugin developers, who should provide
@@ -656,7 +656,7 @@ file is a particular case of a module called a *library file*.
.. cmd:: Print ML Modules
- This prints the name of all OCaml modules loaded with :cmd:`Declare ML Module`.
+ This prints the name of all |OCaml| modules loaded with :cmd:`Declare ML Module`.
To know from where these module were loaded, the user
should use the command :cmd:`Locate File`.
@@ -719,13 +719,13 @@ the toplevel, and using them in source files is discouraged.
.. cmd:: Add ML Path @string
- This command adds the path :n:`@string` to the current OCaml
+ This command adds the path :n:`@string` to the current |OCaml|
loadpath (cf. :cmd:`Declare ML Module`).
.. cmd:: Print ML Path
- This command displays the current OCaml loadpath. This
+ This command displays the current |OCaml| loadpath. This
command makes sense only under the bytecode version of ``coqtop``, i.e.
using option ``-byte``
(cf. :cmd:`Declare ML Module`).
@@ -794,10 +794,10 @@ Quitting and debugging
.. cmd:: Drop
- This command temporarily enters the OCaml toplevel.
+ This command temporarily enters the |OCaml| toplevel.
It is a debug facility used by |Coq|’s implementers. Valid only in the
bytecode version of coqtop.
- The OCaml command:
+ The |OCaml| command:
::
@@ -980,7 +980,7 @@ described first.
This command has an effect on unfoldable constants, i.e. on constants
defined by :cmd:`Definition` or :cmd:`Let` (with an explicit body), or by a command
- assimilated to a definition such as :cmd:`Fixpoint`, :cmd:`Program Definition`, etc,
+ associated with a definition such as :cmd:`Fixpoint`, etc,
or by a proof ended by :cmd:`Defined`. The command tells not to unfold the
constants in the :n:`@reference` sequence in tactics using δ-conversion (unfolding
a constant is replacing it by its definition).
@@ -990,11 +990,6 @@ described first.
has to check the conversion (see Section :ref:`conversion-rules`) of two distinct
applied constants.
- .. seealso::
-
- Sections :ref:`performingcomputations`, :ref:`tactics-automating`,
- :ref:`proof-editing-mode`
-
.. cmd:: Transparent {+ @reference }
This command accepts the :attr:`global` attribute. By default, the scope
@@ -1015,10 +1010,7 @@ described first.
There is no constant named :n:`@qualid` in the environment.
- .. seealso::
-
- Sections :ref:`performingcomputations`,
- :ref:`tactics-automating`, :ref:`proof-editing-mode`
+.. seealso:: :ref:`performingcomputations` and :ref:`proof-editing-mode`
.. _vernac-strategy:
@@ -1230,15 +1222,15 @@ in support libraries of plug-ins.
.. _exposing-constants-to-ocaml-libraries:
-Exposing constants to OCaml libraries
-`````````````````````````````````````
+Exposing constants to |OCaml| libraries
+```````````````````````````````````````
.. cmd:: Register @qualid__1 as @qualid__2
- Makes the constant :n:`@qualid__1` accessible to OCaml libraries under
+ Makes the constant :n:`@qualid__1` accessible to |OCaml| libraries under
the name :n:`@qualid__2`. The constant can then be dynamically located
- in OCaml code by
- calling :n:`Coqlib.lib_ref "@qualid__2"`. The OCaml code doesn't need
+ in |OCaml| code by
+ calling :n:`Coqlib.lib_ref "@qualid__2"`. The |OCaml| code doesn't need
to know where the constant is defined (what file, module, library, etc.).
As a special case, when the first segment of :n:`@qualid__2` is :g:`kernel`,
@@ -1267,7 +1259,7 @@ Registering primitive operations
.. cmd:: Primitive @ident_decl {? : @term } := #@ident
- Makes the primitive type or primitive operator :n:`#@ident` defined in OCaml
+ Makes the primitive type or primitive operator :n:`#@ident` defined in |OCaml|
accessible in |Coq| commands and tactics.
For internal use by implementors of |Coq|'s standard library or standard library
replacements. No space is allowed after the `#`. Invalid values give a syntax
diff --git a/doc/sphinx/proofs/automatic-tactics/auto.rst b/doc/sphinx/proofs/automatic-tactics/auto.rst
new file mode 100644
index 0000000000..cc8af976d2
--- /dev/null
+++ b/doc/sphinx/proofs/automatic-tactics/auto.rst
@@ -0,0 +1,672 @@
+.. _automation:
+
+=========================
+Programmable proof search
+=========================
+
+.. tacn:: auto
+ :name: auto
+
+ This tactic implements a Prolog-like resolution procedure to solve the
+ current goal. It first tries to solve the goal using the :tacn:`assumption`
+ tactic, then it reduces the goal to an atomic one using :tacn:`intros` and
+ introduces the newly generated hypotheses as hints. Then it looks at
+ the list of tactics associated to the head symbol of the goal and
+ tries to apply one of them (starting from the tactics with lower
+ cost). This process is recursively applied to the generated subgoals.
+
+ By default, :tacn:`auto` only uses the hypotheses of the current goal and
+ the hints of the database named ``core``.
+
+ .. warning::
+
+ :tacn:`auto` uses a weaker version of :tacn:`apply` that is closer to
+ :tacn:`simple apply` so it is expected that sometimes :tacn:`auto` will
+ fail even if applying manually one of the hints would succeed.
+
+ .. tacv:: auto @natural
+
+ Forces the search depth to be :token:`natural`. The maximal search depth
+ is 5 by default.
+
+ .. tacv:: auto with {+ @ident}
+
+ Uses the hint databases :n:`{+ @ident}` in addition to the database ``core``.
+
+ .. note::
+
+ Use the fake database `nocore` if you want to *not* use the `core`
+ database.
+
+ .. tacv:: auto with *
+
+ Uses all existing hint databases. Using this variant is highly discouraged
+ in finished scripts since it is both slower and less robust than the variant
+ where the required databases are explicitly listed.
+
+ .. seealso::
+ :ref:`The Hints Databases for auto and eauto <thehintsdatabasesforautoandeauto>` for the list of
+ pre-defined databases and the way to create or extend a database.
+
+ .. tacv:: auto using {+ @qualid__i} {? with {+ @ident } }
+
+ Uses lemmas :n:`@qualid__i` in addition to hints. If :n:`@qualid` is an
+ inductive type, it is the collection of its constructors which are added
+ as hints.
+
+ .. note::
+
+ The hints passed through the `using` clause are used in the same
+ way as if they were passed through a hint database. Consequently,
+ they use a weaker version of :tacn:`apply` and :n:`auto using @qualid`
+ may fail where :n:`apply @qualid` succeeds.
+
+ Given that this can be seen as counter-intuitive, it could be useful
+ to have an option to use full-blown :tacn:`apply` for lemmas passed
+ through the `using` clause. Contributions welcome!
+
+ .. tacv:: info_auto
+
+ Behaves like :tacn:`auto` but shows the tactics it uses to solve the goal. This
+ variant is very useful for getting a better understanding of automation, or
+ to know what lemmas/assumptions were used.
+
+ .. tacv:: debug auto
+ :name: debug auto
+
+ Behaves like :tacn:`auto` but shows the tactics it tries to solve the goal,
+ including failing paths.
+
+ .. tacv:: {? info_}auto {? @natural} {? using {+ @qualid}} {? with {+ @ident}}
+
+ This is the most general form, combining the various options.
+
+.. tacv:: trivial
+ :name: trivial
+
+ This tactic is a restriction of :tacn:`auto` that is not recursive
+ and tries only hints that cost `0`. Typically it solves trivial
+ equalities like :g:`X=X`.
+
+ .. tacv:: trivial with {+ @ident}
+ trivial with *
+ trivial using {+ @qualid}
+ debug trivial
+ info_trivial
+ {? info_}trivial {? using {+ @qualid}} {? with {+ @ident}}
+ :name: _; _; _; debug trivial; info_trivial; _
+ :undocumented:
+
+.. note::
+ :tacn:`auto` and :tacn:`trivial` either solve completely the goal or
+ else succeed without changing the goal. Use :g:`solve [ auto ]` and
+ :g:`solve [ trivial ]` if you would prefer these tactics to fail when
+ they do not manage to solve the goal.
+
+.. flag:: Info Auto
+ Debug Auto
+ Info Trivial
+ Debug Trivial
+
+ These flags enable printing of informative or debug information for
+ the :tacn:`auto` and :tacn:`trivial` tactics.
+
+.. tacn:: eauto
+ :name: eauto
+
+ This tactic generalizes :tacn:`auto`. While :tacn:`auto` does not try
+ resolution hints which would leave existential variables in the goal,
+ :tacn:`eauto` does try them (informally speaking, it internally uses a tactic
+ close to :tacn:`simple eapply` instead of a tactic close to :tacn:`simple apply`
+ in the case of :tacn:`auto`). As a consequence, :tacn:`eauto`
+ can solve such a goal:
+
+ .. example::
+
+ .. coqtop:: all
+
+ Hint Resolve ex_intro : core.
+ Goal forall P:nat -> Prop, P 0 -> exists n, P n.
+ eauto.
+
+ Note that ``ex_intro`` should be declared as a hint.
+
+
+ .. tacv:: {? info_}eauto {? @natural} {? using {+ @qualid}} {? with {+ @ident}}
+
+ The various options for :tacn:`eauto` are the same as for :tacn:`auto`.
+
+ :tacn:`eauto` also obeys the following flags:
+
+ .. flag:: Info Eauto
+ Debug Eauto
+ :undocumented:
+
+ .. seealso:: :ref:`The Hints Databases for auto and eauto <thehintsdatabasesforautoandeauto>`
+
+
+.. tacn:: autounfold with {+ @ident}
+ :name: autounfold
+
+ This tactic unfolds constants that were declared through a :cmd:`Hint Unfold`
+ in the given databases.
+
+.. tacv:: autounfold with {+ @ident} in @goal_occurrences
+
+ Performs the unfolding in the given clause (:token:`goal_occurrences`).
+
+.. tacv:: autounfold with *
+
+ Uses the unfold hints declared in all the hint databases.
+
+.. tacn:: autorewrite with {+ @ident}
+ :name: autorewrite
+
+ This tactic carries out rewritings according to the rewriting rule
+ bases :n:`{+ @ident}`.
+
+ Each rewriting rule from the base :n:`@ident` is applied to the main subgoal until
+ it fails. Once all the rules have been processed, if the main subgoal has
+ progressed (e.g., if it is distinct from the initial main goal) then the rules
+ of this base are processed again. If the main subgoal has not progressed then
+ the next base is processed. For the bases, the behavior is exactly similar to
+ the processing of the rewriting rules.
+
+ The rewriting rule bases are built with the :cmd:`Hint Rewrite`
+ command.
+
+.. warning::
+
+ This tactic may loop if you build non terminating rewriting systems.
+
+.. tacv:: autorewrite with {+ @ident} using @tactic
+
+ Performs, in the same way, all the rewritings of the bases :n:`{+ @ident}`
+ applying tactic to the main subgoal after each rewriting step.
+
+.. tacv:: autorewrite with {+ @ident} in @qualid
+
+ Performs all the rewritings in hypothesis :n:`@qualid`.
+
+.. tacv:: autorewrite with {+ @ident} in @qualid using @tactic
+
+ Performs all the rewritings in hypothesis :n:`@qualid` applying :n:`@tactic`
+ to the main subgoal after each rewriting step.
+
+.. tacv:: autorewrite with {+ @ident} in @goal_occurrences
+
+ Performs all the rewriting in the clause :n:`@goal_occurrences`.
+
+.. seealso::
+
+ :ref:`Hint-Rewrite <hintrewrite>` for feeding the database of lemmas used by
+ :tacn:`autorewrite` and :tacn:`autorewrite` for examples showing the use of this tactic.
+
+.. tacn:: easy
+ :name: easy
+
+ This tactic tries to solve the current goal by a number of standard closing steps.
+ In particular, it tries to close the current goal using the closing tactics
+ :tacn:`trivial`, :tacn:`reflexivity`, :tacn:`symmetry`, :tacn:`contradiction`
+ and :tacn:`inversion` of hypothesis.
+ If this fails, it tries introducing variables and splitting and-hypotheses,
+ using the closing tactics afterwards, and splitting the goal using
+ :tacn:`split` and recursing.
+
+ This tactic solves goals that belong to many common classes; in particular, many cases of
+ unsatisfiable hypotheses, and simple equality goals are usually solved by this tactic.
+
+.. tacv:: now @tactic
+ :name: now
+
+ Run :n:`@tactic` followed by :tacn:`easy`. This is a notation for :n:`@tactic; easy`.
+
+Controlling automation
+--------------------------
+
+.. _thehintsdatabasesforautoandeauto:
+
+The hints databases for auto and eauto
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The hints for :tacn:`auto` and :tacn:`eauto` are stored in databases. Each database
+maps head symbols to a list of hints.
+
+.. cmd:: Print Hint @ident
+
+ Use this command
+ to display the hints associated to the head symbol :n:`@ident`
+ (see :ref:`Print Hint <printhint>`). Each hint has a cost that is a nonnegative
+ integer, and an optional pattern. The hints with lower cost are tried first. A
+ hint is tried by :tacn:`auto` when the conclusion of the current goal matches its
+ pattern or when it has no pattern.
+
+Creating Hint databases
+```````````````````````
+
+One can optionally declare a hint database using the command
+:cmd:`Create HintDb`. If a hint is added to an unknown database, it will be
+automatically created.
+
+.. cmd:: Create HintDb @ident {? discriminated}
+
+ This command creates a new database named :n:`@ident`. The database is
+ implemented by a Discrimination Tree (DT) that serves as an index of
+ all the lemmas. The DT can use transparency information to decide if a
+ constant should be indexed or not
+ (c.f. :ref:`The hints databases for auto and eauto <thehintsdatabasesforautoandeauto>`),
+ making the retrieval more efficient. The legacy implementation (the default one
+ for new databases) uses the DT only on goals without existentials (i.e., :tacn:`auto`
+ goals), for non-Immediate hints and does not make use of transparency
+ hints, putting more work on the unification that is run after
+ retrieval (it keeps a list of the lemmas in case the DT is not used).
+ The new implementation enabled by the discriminated option makes use
+ of DTs in all cases and takes transparency information into account.
+ However, the order in which hints are retrieved from the DT may differ
+ from the order in which they were inserted, making this implementation
+ observationally different from the legacy one.
+
+.. cmd:: Hint @hint_definition : {+ @ident}
+
+ The general command to add a hint to some databases :n:`{+ @ident}`.
+
+ This command supports the :attr:`local`, :attr:`global` and :attr:`export`
+ locality attributes. When no locality is explictly given, the
+ command is :attr:`local` inside a section and :attr:`global` otherwise.
+
+ + :attr:`local` hints are never visible from other modules, even if they
+ require or import the current module. Inside a section, the :attr:`local`
+ attribute is useless since hints do not survive anyway to the closure of
+ sections.
+
+ + :attr:`export` are visible from other modules when they import the current
+ module. Requiring it is not enough. This attribute is only effective for
+ the :cmd:`Hint Resolve`, :cmd:`Hint Immediate`, :cmd:`Hint Unfold` and
+ :cmd:`Hint Extern` variants of the command.
+
+ + :attr:`global` hints are made available by merely requiring the current
+ module.
+
+ The various possible :production:`hint_definition`\s are given below.
+
+ .. cmdv:: Hint @hint_definition
+
+ No database name is given: the hint is registered in the ``core`` database.
+
+ .. deprecated:: 8.10
+
+ .. cmdv:: Hint Resolve @qualid {? | {? @natural} {? @pattern}} : @ident
+ :name: Hint Resolve
+
+ This command adds :n:`simple apply @qualid` to the hint list with the head
+ symbol of the type of :n:`@qualid`. The cost of that hint is the number of
+ subgoals generated by :n:`simple apply @qualid` or :n:`@natural` if specified. The
+ associated :n:`@pattern` is inferred from the conclusion of the type of
+ :n:`@qualid` or the given :n:`@pattern` if specified. In case the inferred type
+ of :n:`@qualid` does not start with a product the tactic added in the hint list
+ is :n:`exact @qualid`. In case this type can however be reduced to a type
+ starting with a product, the tactic :n:`simple apply @qualid` is also stored in
+ the hints list. If the inferred type of :n:`@qualid` contains a dependent
+ quantification on a variable which occurs only in the premisses of the type
+ and not in its conclusion, no instance could be inferred for the variable by
+ unification with the goal. In this case, the hint is added to the hint list
+ of :tacn:`eauto` instead of the hint list of auto and a warning is printed. A
+ typical example of a hint that is used only by :tacn:`eauto` is a transitivity
+ lemma.
+
+ .. exn:: @qualid cannot be used as a hint
+
+ The head symbol of the type of :n:`@qualid` is a bound variable
+ such that this tactic cannot be associated to a constant.
+
+ .. cmdv:: Hint Resolve {+ @qualid} : @ident
+
+ Adds each :n:`Hint Resolve @qualid`.
+
+ .. cmdv:: Hint Resolve -> @qualid : @ident
+
+ Adds the left-to-right implication of an equivalence as a hint (informally
+ the hint will be used as :n:`apply <- @qualid`, although as mentioned
+ before, the tactic actually used is a restricted version of
+ :tacn:`apply`).
+
+ .. cmdv:: Hint Resolve <- @qualid
+
+ Adds the right-to-left implication of an equivalence as a hint.
+
+ .. cmdv:: Hint Immediate @qualid : @ident
+ :name: Hint Immediate
+
+ This command adds :n:`simple apply @qualid; trivial` to the hint list associated
+ with the head symbol of the type of :n:`@ident` in the given database. This
+ tactic will fail if all the subgoals generated by :n:`simple apply @qualid` are
+ not solved immediately by the :tacn:`trivial` tactic (which only tries tactics
+ with cost 0).This command is useful for theorems such as the symmetry of
+ equality or :g:`n+1=m+1 -> n=m` that we may like to introduce with a limited
+ use in order to avoid useless proof-search. The cost of this tactic (which
+ never generates subgoals) is always 1, so that it is not used by :tacn:`trivial`
+ itself.
+
+ .. exn:: @qualid cannot be used as a hint
+ :undocumented:
+
+ .. cmdv:: Hint Immediate {+ @qualid} : @ident
+
+ Adds each :n:`Hint Immediate @qualid`.
+
+ .. cmdv:: Hint Constructors @qualid : @ident
+ :name: Hint Constructors
+
+ If :token:`qualid` is an inductive type, this command adds all its constructors as
+ hints of type ``Resolve``. Then, when the conclusion of current goal has the form
+ :n:`(@qualid ...)`, :tacn:`auto` will try to apply each constructor.
+
+ .. exn:: @qualid is not an inductive type
+ :undocumented:
+
+ .. cmdv:: Hint Constructors {+ @qualid} : @ident
+
+ Extends the previous command for several inductive types.
+
+ .. cmdv:: Hint Unfold @qualid : @ident
+ :name: Hint Unfold
+
+ This adds the tactic :n:`unfold @qualid` to the hint list that will only be
+ used when the head constant of the goal is :token:`qualid`.
+ Its cost is 4.
+
+ .. cmdv:: Hint Unfold {+ @qualid}
+
+ Extends the previous command for several defined constants.
+
+ .. cmdv:: Hint Transparent {+ @qualid} : @ident
+ Hint Opaque {+ @qualid} : @ident
+ :name: Hint Transparent; Hint Opaque
+
+ This adds transparency hints to the database, making :n:`@qualid`
+ transparent or opaque constants during resolution. This information is used
+ during unification of the goal with any lemma in the database and inside the
+ discrimination network to relax or constrain it in the case of discriminated
+ databases.
+
+ .. cmdv:: Hint Variables {| Transparent | Opaque } : @ident
+ Hint Constants {| Transparent | Opaque } : @ident
+ :name: Hint Variables; Hint Constants
+
+ This sets the transparency flag used during unification of
+ hints in the database for all constants or all variables,
+ overwriting the existing settings of opacity. It is advised
+ to use this just after a :cmd:`Create HintDb` command.
+
+ .. cmdv:: Hint Extern @natural {? @pattern} => @tactic : @ident
+ :name: Hint Extern
+
+ This hint type is to extend :tacn:`auto` with tactics other than :tacn:`apply` and
+ :tacn:`unfold`. For that, we must specify a cost, an optional :n:`@pattern` and a
+ :n:`@tactic` to execute.
+
+ .. example::
+
+ .. coqtop:: in
+
+ Hint Extern 4 (~(_ = _)) => discriminate : core.
+
+ Now, when the head of the goal is a disequality, ``auto`` will try
+ discriminate if it does not manage to solve the goal with hints with a
+ cost less than 4.
+
+ One can even use some sub-patterns of the pattern in
+ the tactic script. A sub-pattern is a question mark followed by an
+ identifier, like ``?X1`` or ``?X2``. Here is an example:
+
+ .. example::
+
+ .. coqtop:: reset all
+
+ Require Import List.
+ Hint Extern 5 ({?X1 = ?X2} + {?X1 <> ?X2}) => generalize X1, X2; decide equality : eqdec.
+ Goal forall a b:list (nat * nat), {a = b} + {a <> b}.
+ Info 1 auto with eqdec.
+
+ .. cmdv:: Hint Cut @regexp : @ident
+ :name: Hint Cut
+
+ .. warning::
+
+ These hints currently only apply to typeclass proof search and the
+ :tacn:`typeclasses eauto` tactic.
+
+ This command can be used to cut the proof-search tree according to a regular
+ expression matching paths to be cut. The grammar for regular expressions is
+ the following. Beware, there is no operator precedence during parsing, one can
+ check with :cmd:`Print HintDb` to verify the current cut expression:
+
+ .. prodn::
+ regexp ::= @ident (hint or instance identifier)
+ | _ (any hint)
+ | @regexp | @regexp (disjunction)
+ | @regexp @regexp (sequence)
+ | @regexp * (Kleene star)
+ | emp (empty)
+ | eps (epsilon)
+ | ( @regexp )
+
+ The `emp` regexp does not match any search path while `eps`
+ matches the empty path. During proof search, the path of
+ successive successful hints on a search branch is recorded, as a
+ list of identifiers for the hints (note that :cmd:`Hint Extern`\’s do not have
+ an associated identifier).
+ Before applying any hint :n:`@ident` the current path `p` extended with
+ :n:`@ident` is matched against the current cut expression `c` associated to
+ the hint database. If matching succeeds, the hint is *not* applied. The
+ semantics of :n:`Hint Cut @regexp` is to set the cut expression
+ to :n:`c | regexp`, the initial cut expression being `emp`.
+
+ .. cmdv:: Hint Mode @qualid {* {| + | ! | - } } : @ident
+ :name: Hint Mode
+
+ This sets an optional mode of use of the identifier :n:`@qualid`. When
+ proof-search faces a goal that ends in an application of :n:`@qualid` to
+ arguments :n:`@term ... @term`, the mode tells if the hints associated to
+ :n:`@qualid` can be applied or not. A mode specification is a list of n ``+``,
+ ``!`` or ``-`` items that specify if an argument of the identifier is to be
+ treated as an input (``+``), if its head only is an input (``!``) or an output
+ (``-``) of the identifier. For a mode to match a list of arguments, input
+ terms and input heads *must not* contain existential variables or be
+ existential variables respectively, while outputs can be any term. Multiple
+ modes can be declared for a single identifier, in that case only one mode
+ needs to match the arguments for the hints to be applied. The head of a term
+ is understood here as the applicative head, or the match or projection
+ scrutinee’s head, recursively, casts being ignored. :cmd:`Hint Mode` is
+ especially useful for typeclasses, when one does not want to support default
+ instances and avoid ambiguity in general. Setting a parameter of a class as an
+ input forces proof-search to be driven by that index of the class, with ``!``
+ giving more flexibility by allowing existentials to still appear deeper in the
+ index but not at its head.
+
+ .. note::
+
+ + One can use a :cmd:`Hint Extern` with no pattern to do
+ pattern matching on hypotheses using ``match goal with``
+ inside the tactic.
+
+ + If you want to add hints such as :cmd:`Hint Transparent`,
+ :cmd:`Hint Cut`, or :cmd:`Hint Mode`, for typeclass
+ resolution, do not forget to put them in the
+ ``typeclass_instances`` hint database.
+
+
+Hint databases defined in the |Coq| standard library
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Several hint databases are defined in the |Coq| standard library. The
+actual content of a database is the collection of hints declared
+to belong to this database in each of the various modules currently
+loaded. Especially, requiring new modules may extend the database.
+At |Coq| startup, only the core database is nonempty and can be used.
+
+:core: This special database is automatically used by ``auto``, except when
+ pseudo-database ``nocore`` is given to ``auto``. The core database
+ contains only basic lemmas about negation, conjunction, and so on.
+ Most of the hints in this database come from the Init and Logic directories.
+
+:arith: This database contains all lemmas about Peano’s arithmetic proved in the
+ directories Init and Arith.
+
+:zarith: contains lemmas about binary signed integers from the
+ directories theories/ZArith. The database also contains
+ high-cost hints that call :tacn:`lia` on equations and
+ inequalities in ``nat`` or ``Z``.
+
+:bool: contains lemmas about booleans, mostly from directory theories/Bool.
+
+:datatypes: is for lemmas about lists, streams and so on that are mainly proved
+ in the Lists subdirectory.
+
+:sets: contains lemmas about sets and relations from the directories Sets and
+ Relations.
+
+:typeclass_instances: contains all the typeclass instances declared in the
+ environment, including those used for ``setoid_rewrite``,
+ from the Classes directory.
+
+:fset: internal database for the implementation of the ``FSets`` library.
+
+:ordered_type: lemmas about ordered types (as defined in the legacy ``OrderedType`` module),
+ mainly used in the ``FSets`` and ``FMaps`` libraries.
+
+You are advised not to put your own hints in the core database, but
+use one or several databases specific to your development.
+
+.. _removehints:
+
+.. cmd:: Remove Hints {+ @term} : {+ @ident}
+
+ This command removes the hints associated to terms :n:`{+ @term}` in databases
+ :n:`{+ @ident}`.
+
+.. _printhint:
+
+.. cmd:: Print Hint
+
+ This command displays all hints that apply to the current goal. It
+ fails if no proof is being edited, while the two variants can be used
+ at every moment.
+
+**Variants:**
+
+
+.. cmd:: Print Hint @ident
+
+ This command displays only tactics associated with :n:`@ident` in the hints
+ list. This is independent of the goal being edited, so this command will not
+ fail if no goal is being edited.
+
+.. cmd:: Print Hint *
+
+ This command displays all declared hints.
+
+.. cmd:: Print HintDb @ident
+
+ This command displays all hints from database :n:`@ident`.
+
+.. _hintrewrite:
+
+.. cmd:: Hint Rewrite {+ @term} : {+ @ident}
+
+ This vernacular command adds the terms :n:`{+ @term}` (their types must be
+ equalities) in the rewriting bases :n:`{+ @ident}` with the default orientation
+ (left to right). Notice that the rewriting bases are distinct from the :tacn:`auto`
+ hint bases and that :tacn:`auto` does not take them into account.
+
+ This command is synchronous with the section mechanism (see :ref:`section-mechanism`):
+ when closing a section, all aliases created by ``Hint Rewrite`` in that
+ section are lost. Conversely, when loading a module, all ``Hint Rewrite``
+ declarations at the global level of that module are loaded.
+
+**Variants:**
+
+.. cmd:: Hint Rewrite -> {+ @term} : {+ @ident}
+
+ This is strictly equivalent to the command above (we only make explicit the
+ orientation which otherwise defaults to ->).
+
+.. cmd:: Hint Rewrite <- {+ @term} : {+ @ident}
+
+ Adds the rewriting rules :n:`{+ @term}` with a right-to-left orientation in
+ the bases :n:`{+ @ident}`.
+
+.. cmd:: Hint Rewrite {? {| -> | <- } } {+ @one_term } {? using @ltac_expr } {? : {* @ident } }
+
+ When the rewriting rules :n:`{+ @term}` in :n:`{+ @ident}` will be used, the
+ tactic ``tactic`` will be applied to the generated subgoals, the main subgoal
+ excluded.
+
+.. cmd:: Print Rewrite HintDb @ident
+
+ This command displays all rewrite hints contained in :n:`@ident`.
+
+Hint locality
+~~~~~~~~~~~~~
+
+Hints provided by the ``Hint`` commands are erased when closing a section.
+Conversely, all hints of a module ``A`` that are not defined inside a
+section (and not defined with option ``Local``) become available when the
+module ``A`` is required (using e.g. ``Require A.``).
+
+As of today, hints only have a binary behavior regarding locality, as
+described above: either they disappear at the end of a section scope,
+or they remain global forever. This causes a scalability issue,
+because hints coming from an unrelated part of the code may badly
+influence another development. It can be mitigated to some extent
+thanks to the :cmd:`Remove Hints` command,
+but this is a mere workaround and has some limitations (for instance, external
+hints cannot be removed).
+
+A proper way to fix this issue is to bind the hints to their module scope, as
+for most of the other objects |Coq| uses. Hints should only be made available when
+the module they are defined in is imported, not just required. It is very
+difficult to change the historical behavior, as it would break a lot of scripts.
+We propose a smooth transitional path by providing the :opt:`Loose Hint Behavior`
+option which accepts three flags allowing for a fine-grained handling of
+non-imported hints.
+
+.. opt:: Loose Hint Behavior {| "Lax" | "Warn" | "Strict" }
+ :name: Loose Hint Behavior
+
+ This option accepts three values, which control the behavior of hints w.r.t.
+ :cmd:`Import`:
+
+ - "Lax": this is the default, and corresponds to the historical behavior,
+ that is, hints defined outside of a section have a global scope.
+
+ - "Warn": outputs a warning when a non-imported hint is used. Note that this
+ is an over-approximation, because a hint may be triggered by a run that
+ will eventually fail and backtrack, resulting in the hint not being
+ actually useful for the proof.
+
+ - "Strict": changes the behavior of an unloaded hint to a immediate fail
+ tactic, allowing to emulate an import-scoped hint mechanism.
+
+.. _tactics-implicit-automation:
+
+Setting implicit automation tactics
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. cmd:: Proof with @tactic
+
+ This command may be used to start a proof. It defines a default tactic
+ to be used each time a tactic command ``tactic``:sub:`1` is ended by ``...``.
+ In this case the tactic command typed by the user is equivalent to
+ ``tactic``:sub:`1` ``;tactic``.
+
+ .. seealso:: :cmd:`Proof` in :ref:`proof-editing-mode`.
+
+
+ .. cmdv:: Proof with @tactic using {+ @ident}
+
+ Combines in a single line ``Proof with`` and ``Proof using``, see :ref:`proof-editing-mode`
+
+ .. cmdv:: Proof using {+ @ident} with @tactic
+
+ Combines in a single line ``Proof with`` and ``Proof using``, see :ref:`proof-editing-mode`
diff --git a/doc/sphinx/proofs/automatic-tactics/index.rst b/doc/sphinx/proofs/automatic-tactics/index.rst
index a219770c69..c3712b109d 100644
--- a/doc/sphinx/proofs/automatic-tactics/index.rst
+++ b/doc/sphinx/proofs/automatic-tactics/index.rst
@@ -1,20 +1,22 @@
.. _automatic-tactics:
=====================================================
-Built-in decision procedures and programmable tactics
+Automatic solvers and programmable tactics
=====================================================
Some tactics are largely automated and are able to solve complex
-goals. This chapter presents both some decision procedures that can
-be used to solve some specific categories of goals, and some
-programmable tactics, that the user can instrument to handle some
+goals. This chapter presents both built-in solvers that can
+be used on specific categories of goals and
+programmable tactics that the user can instrument to handle
complex goals in new domains.
.. toctree::
:maxdepth: 1
+ logic
../../addendum/omega
../../addendum/micromega
../../addendum/ring
../../addendum/nsatz
+ auto
../../addendum/generalized-rewriting
diff --git a/doc/sphinx/proofs/automatic-tactics/logic.rst b/doc/sphinx/proofs/automatic-tactics/logic.rst
new file mode 100644
index 0000000000..acf64ae437
--- /dev/null
+++ b/doc/sphinx/proofs/automatic-tactics/logic.rst
@@ -0,0 +1,294 @@
+.. _decisionprocedures:
+
+==============================
+Solvers for logic and equality
+==============================
+
+.. tacn:: tauto
+ :name: tauto
+
+ This tactic implements a decision procedure for intuitionistic propositional
+ calculus based on the contraction-free sequent calculi LJT* of Roy Dyckhoff
+ :cite:`Dyc92`. Note that :tacn:`tauto` succeeds on any instance of an
+ intuitionistic tautological proposition. :tacn:`tauto` unfolds negations and
+ logical equivalence but does not unfold any other definition.
+
+.. example::
+
+ The following goal can be proved by :tacn:`tauto` whereas :tacn:`auto` would
+ fail:
+
+ .. coqtop:: reset all
+
+ Goal forall (x:nat) (P:nat -> Prop), x = 0 \/ P x -> x <> 0 -> P x.
+ intros.
+ tauto.
+
+Moreover, if it has nothing else to do, :tacn:`tauto` performs introductions.
+Therefore, the use of :tacn:`intros` in the previous proof is unnecessary.
+:tacn:`tauto` can for instance for:
+
+.. example::
+
+ .. coqtop:: reset all
+
+ Goal forall (A:Prop) (P:nat -> Prop), A \/ (forall x:nat, ~ A -> P x) -> forall x:nat, ~ A -> P x.
+ tauto.
+
+.. note::
+ In contrast, :tacn:`tauto` cannot solve the following goal
+ :g:`Goal forall (A:Prop) (P:nat -> Prop), A \/ (forall x:nat, ~ A -> P x) ->`
+ :g:`forall x:nat, ~ ~ (A \/ P x).`
+ because :g:`(forall x:nat, ~ A -> P x)` cannot be treated as atomic and
+ an instantiation of `x` is necessary.
+
+.. tacv:: dtauto
+ :name: dtauto
+
+ While :tacn:`tauto` recognizes inductively defined connectives isomorphic to
+ the standard connectives ``and``, ``prod``, ``or``, ``sum``, ``False``,
+ ``Empty_set``, ``unit``, ``True``, :tacn:`dtauto` also recognizes all inductive
+ types with one constructor and no indices, i.e. record-style connectives.
+
+.. tacn:: intuition @tactic
+ :name: intuition
+
+ The tactic :tacn:`intuition` takes advantage of the search-tree built by the
+ decision procedure involved in the tactic :tacn:`tauto`. It uses this
+ information to generate a set of subgoals equivalent to the original one (but
+ simpler than it) and applies the tactic :n:`@tactic` to them :cite:`Mun94`. If
+ this tactic fails on some goals then :tacn:`intuition` fails. In fact,
+ :tacn:`tauto` is simply :g:`intuition fail`.
+
+ .. example::
+
+ For instance, the tactic :g:`intuition auto` applied to the goal::
+
+ (forall (x:nat), P x) /\ B -> (forall (y:nat), P y) /\ P O \/ B /\ P O
+
+ internally replaces it by the equivalent one::
+
+ (forall (x:nat), P x), B |- P O
+
+ and then uses :tacn:`auto` which completes the proof.
+
+Originally due to César Muñoz, these tactics (:tacn:`tauto` and
+:tacn:`intuition`) have been completely re-engineered by David Delahaye using
+mainly the tactic language (see :ref:`ltac`). The code is
+now much shorter and a significant increase in performance has been noticed.
+The general behavior with respect to dependent types, unfolding and
+introductions has slightly changed to get clearer semantics. This may lead to
+some incompatibilities.
+
+.. tacv:: intuition
+
+ Is equivalent to :g:`intuition auto with *`.
+
+.. tacv:: dintuition
+ :name: dintuition
+
+ While :tacn:`intuition` recognizes inductively defined connectives
+ isomorphic to the standard connectives ``and``, ``prod``, ``or``, ``sum``, ``False``,
+ ``Empty_set``, ``unit``, ``True``, :tacn:`dintuition` also recognizes all inductive
+ types with one constructor and no indices, i.e. record-style connectives.
+
+.. flag:: Intuition Negation Unfolding
+
+ Controls whether :tacn:`intuition` unfolds inner negations which do not need
+ to be unfolded. This flag is on by default.
+
+.. tacn:: rtauto
+ :name: rtauto
+
+ The :tacn:`rtauto` tactic solves propositional tautologies similarly to what
+ :tacn:`tauto` does. The main difference is that the proof term is built using a
+ reflection scheme applied to a sequent calculus proof of the goal. The search
+ procedure is also implemented using a different technique.
+
+ Users should be aware that this difference may result in faster proof-search
+ but slower proof-checking, and :tacn:`rtauto` might not solve goals that
+ :tacn:`tauto` would be able to solve (e.g. goals involving universal
+ quantifiers).
+
+ Note that this tactic is only available after a ``Require Import Rtauto``.
+
+.. tacn:: firstorder
+ :name: firstorder
+
+ The tactic :tacn:`firstorder` is an experimental extension of :tacn:`tauto` to
+ first- order reasoning, written by Pierre Corbineau. It is not restricted to
+ usual logical connectives but instead may reason about any first-order class
+ inductive definition.
+
+.. opt:: Firstorder Solver @tactic
+ :name: Firstorder Solver
+
+ The default tactic used by :tacn:`firstorder` when no rule applies is
+ :g:`auto with core`, it can be reset locally or globally using this option.
+
+ .. cmd:: Print Firstorder Solver
+
+ Prints the default tactic used by :tacn:`firstorder` when no rule applies.
+
+.. tacv:: firstorder @tactic
+
+ Tries to solve the goal with :n:`@tactic` when no logical rule may apply.
+
+.. tacv:: firstorder using {+ @qualid}
+
+ .. deprecated:: 8.3
+
+ Use the syntax below instead (with commas).
+
+.. tacv:: firstorder using {+, @qualid}
+
+ Adds lemmas :n:`{+, @qualid}` to the proof-search environment. If :n:`@qualid`
+ refers to an inductive type, it is the collection of its constructors which are
+ added to the proof-search environment.
+
+.. tacv:: firstorder with {+ @ident}
+
+ Adds lemmas from :tacn:`auto` hint bases :n:`{+ @ident}` to the proof-search
+ environment.
+
+.. tacv:: firstorder @tactic using {+, @qualid} with {+ @ident}
+
+ This combines the effects of the different variants of :tacn:`firstorder`.
+
+.. opt:: Firstorder Depth @natural
+ :name: Firstorder Depth
+
+ This option controls the proof-search depth bound.
+
+.. tacn:: congruence
+ :name: congruence
+
+ The tactic :tacn:`congruence`, by Pierre Corbineau, implements the standard
+ Nelson and Oppen congruence closure algorithm, which is a decision procedure
+ for ground equalities with uninterpreted symbols. It also includes
+ constructor theory (see :tacn:`injection` and :tacn:`discriminate`). If the goal
+ is a non-quantified equality, congruence tries to prove it with non-quantified
+ equalities in the context. Otherwise it tries to infer a discriminable equality
+ from those in the context. Alternatively, congruence tries to prove that a
+ hypothesis is equal to the goal or to the negation of another hypothesis.
+
+ :tacn:`congruence` is also able to take advantage of hypotheses stating
+ quantified equalities, but you have to provide a bound for the number of extra
+ equalities generated that way. Please note that one of the sides of the
+ 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.
+ intros.
+ congruence.
+ Qed.
+
+ Theorem inj (A:Type) (f:A -> A * A) (a c d: A) : f = pair a -> Some (f c) = Some (f d) -> c=d.
+ intros.
+ congruence.
+ Qed.
+
+.. tacv:: congruence @natural
+
+ Tries to add at most :token:`natural` instances of hypotheses stating quantified equalities
+ to the problem in order to solve it. A bigger value of :token:`natural` does not make
+ success slower, only failure. You might consider adding some lemmas as
+ hypotheses using assert in order for :tacn:`congruence` to use them.
+
+.. tacv:: congruence with {+ @term}
+ :name: congruence with
+
+ Adds :n:`{+ @term}` to the pool of terms used by :tacn:`congruence`. This helps
+ in case you have partially applied constructors in your goal.
+
+.. exn:: I don’t know how to handle dependent equality.
+
+ The decision procedure managed to find a proof of the goal or of a
+ 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 {+ @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
+ appropriate type will allow the tactic to successfully solve the goal. Those
+ additional arguments can be given to congruence by filling in the holes in the
+ terms given in the error message, using the :tacn:`congruence with` variant described above.
+
+.. flag:: Congruence Verbose
+
+ This flag makes :tacn:`congruence` print debug information.
+
+.. tacn:: btauto
+ :name: btauto
+
+ The tactic :tacn:`btauto` implements a reflexive solver for boolean
+ tautologies. It solves goals of the form :g:`t = u` where `t` and `u` are
+ constructed over the following grammar:
+
+ .. prodn::
+ btauto_term ::= @ident
+ | true
+ | false
+ | orb @btauto_term @btauto_term
+ | andb @btauto_term @btauto_term
+ | xorb @btauto_term @btauto_term
+ | negb @btauto_term
+ | if @btauto_term then @btauto_term else @btauto_term
+
+ Whenever the formula supplied is not a tautology, it also provides a
+ counter-example.
+
+ Internally, it uses a system very similar to the one of the ring
+ tactic.
+
+ Note that this tactic is only available after a ``Require Import Btauto``.
+
+ .. exn:: Cannot recognize a boolean equality.
+
+ The goal is not of the form :g:`t = u`. Especially note that :tacn:`btauto`
+ doesn't introduce variables into the context on its own.
+
+.. tacv:: field
+ field_simplify {* @term}
+ field_simplify_eq
+
+ The field tactic is built on the same ideas as ring: this is a
+ reflexive tactic that solves or simplifies equations in a field
+ structure. The main idea is to reduce a field expression (which is an
+ extension of ring expressions with the inverse and division
+ operations) to a fraction made of two polynomial expressions.
+
+ Tactic :n:`field` is used to solve subgoals, whereas :n:`field_simplify {+ @term}`
+ replaces the provided terms by their reduced fraction.
+ :n:`field_simplify_eq` applies when the conclusion is an equation: it
+ simplifies both hand sides and multiplies so as to cancel
+ denominators. So it produces an equation without division nor inverse.
+
+ All of these 3 tactics may generate a subgoal in order to prove that
+ denominators are different from zero.
+
+ See :ref:`Theringandfieldtacticfamilies` for more information on the tactic and how to
+ declare new field structures. All declared field structures can be
+ printed with the Print Fields command.
+
+.. example::
+
+ .. coqtop:: reset all
+
+ Require Import Reals.
+ Goal forall x y:R,
+ (x * y > 0)%R ->
+ (x * (1 / x + x / (x + y)))%R =
+ ((- 1 / y) * y * (- x * (x / (x + y)) - 1))%R.
+
+ intros; field.
+
+.. seealso::
+
+ File plugins/ring/RealField.v for an example of instantiation,
+ theory theories/Reals for many examples of use of field.
diff --git a/doc/sphinx/proofs/creating-tactics/index.rst b/doc/sphinx/proofs/creating-tactics/index.rst
index 1af1b0b726..f1d4fa789d 100644
--- a/doc/sphinx/proofs/creating-tactics/index.rst
+++ b/doc/sphinx/proofs/creating-tactics/index.rst
@@ -18,13 +18,13 @@ new tactics:
- `Mtac2 <https://github.com/Mtac2/Mtac2>`_ is an external plugin
which provides another typed tactic language. While Ltac2 belongs
- to the ML language family, Mtac2 reuses the language of Coq itself
- as the language to build Coq tactics.
+ to the ML language family, Mtac2 reuses the language of |Coq| itself
+ as the language to build |Coq| tactics.
- The most traditional way of building new complex tactics is to write
- a Coq plugin in OCaml. Beware that this also requires much more
- effort and commitment. A tutorial for writing Coq plugins is
- available in the Coq repository in `doc/plugin_tutorial
+ a |Coq| plugin in |OCaml|. Beware that this also requires much more
+ effort and commitment. A tutorial for writing |Coq| plugins is
+ available in the |Coq| repository in `doc/plugin_tutorial
<https://github.com/coq/coq/tree/master/doc/plugin_tutorial>`_.
.. toctree::
diff --git a/doc/sphinx/proofs/writing-proofs/index.rst b/doc/sphinx/proofs/writing-proofs/index.rst
index a279a5957f..1c7fd050f1 100644
--- a/doc/sphinx/proofs/writing-proofs/index.rst
+++ b/doc/sphinx/proofs/writing-proofs/index.rst
@@ -1,10 +1,10 @@
.. _writing-proofs:
-==============
-Writing proofs
-==============
+===================
+Basic proof writing
+===================
-Coq is an interactive theorem prover, or proof assistant, which means
+|Coq| is an interactive theorem prover, or proof assistant, which means
that proofs can be constructed interactively through a dialog between
the user and the assistant. The building blocks for this dialog are
tactics which the user will use to represent steps in the proof of a
@@ -27,8 +27,9 @@ flavors of tactics, including the SSReflect proof language.
.. toctree::
:maxdepth: 1
- ../../proof-engine/proof-handling
+ proof-mode
../../proof-engine/tactics
+ rewriting
../../proof-engine/ssreflect-proof-language
../../proof-engine/detailed-tactic-examples
../../user-extensions/proof-schemes
diff --git a/doc/sphinx/proofs/writing-proofs/proof-mode.rst b/doc/sphinx/proofs/writing-proofs/proof-mode.rst
new file mode 100644
index 0000000000..b74c9d3a23
--- /dev/null
+++ b/doc/sphinx/proofs/writing-proofs/proof-mode.rst
@@ -0,0 +1,1037 @@
+.. _proofhandling:
+
+-------------------
+ Proof handling
+-------------------
+
+In |Coq|’s proof editing mode all top-level commands documented in
+Chapter :ref:`vernacularcommands` remain available and the user has access to specialized
+commands dealing with proof development pragmas documented in this
+section. They can also use some other specialized commands called
+*tactics*. They are the very tools allowing the user to deal with
+logical reasoning. They are documented in Chapter :ref:`tactics`.
+
+|Coq| user interfaces usually have a way of marking whether the user has
+switched to proof editing mode. For instance, in coqtop the prompt ``Coq <``   is changed into
+:n:`@ident <`   where :token:`ident` is the declared name of the theorem currently edited.
+
+At each stage of a proof development, one has a list of goals to
+prove. Initially, the list consists only in the theorem itself. After
+having applied some tactics, the list of goals contains the subgoals
+generated by the tactics.
+
+To each subgoal is associated a number of hypotheses called the *local context*
+of the goal. Initially, the local context contains the local variables and
+hypotheses of the current section (see Section :ref:`gallina-assumptions`) and
+the local variables and hypotheses of the theorem statement. It is enriched by
+the use of certain tactics (see e.g. :tacn:`intro`).
+
+When a proof is completed, the message ``Proof completed`` is displayed.
+One can then register this proof as a defined constant in the
+environment. Because there exists a correspondence between proofs and
+terms of λ-calculus, known as the *Curry-Howard isomorphism*
+:cite:`How80,Bar81,Gir89,H89`, |Coq| stores proofs as terms of |Cic|. Those
+terms are called *proof terms*.
+
+
+.. exn:: No focused proof.
+
+ |Coq| raises this error message when one attempts to use a proof editing command
+ out of the proof editing mode.
+
+.. _proof-editing-mode:
+
+Entering and leaving proof editing mode
+---------------------------------------
+
+The proof editing mode is entered by asserting a statement, which typically is
+the assertion of a theorem using an assertion command like :cmd:`Theorem`. The
+list of assertion commands is given in :ref:`Assertions`. The command
+:cmd:`Goal` can also be used.
+
+.. cmd:: Goal @type
+
+ This is intended for quick assertion of statements, without knowing in
+ advance which name to give to the assertion, typically for quick
+ testing of the provability of a statement. If the proof of the
+ statement is eventually completed and validated, the statement is then
+ bound to the name ``Unnamed_thm`` (or a variant of this name not already
+ used for another statement).
+
+.. cmd:: Qed
+
+ This command is available in interactive editing proof mode when the
+ proof is completed. Then :cmd:`Qed` extracts a proof term from the proof
+ script, switches back to |Coq| top-level and attaches the extracted
+ proof term to the declared name of the original goal. The name is
+ added to the environment as an opaque constant.
+
+ .. exn:: Attempt to save an incomplete proof.
+ :undocumented:
+
+ .. note::
+
+ Sometimes an error occurs when building the proof term, because
+ tactics do not enforce completely the term construction
+ constraints.
+
+ The user should also be aware of the fact that since the
+ proof term is completely rechecked at this point, one may have to wait
+ a while when the proof is large. In some exceptional cases one may
+ even incur a memory overflow.
+
+.. cmd:: Save @ident
+ :name: Save
+
+ Saves a completed proof with the name :token:`ident`, which
+ overrides any name provided by the :cmd:`Theorem` command or
+ its variants.
+
+.. cmd:: Defined {? @ident }
+
+ Similar to :cmd:`Qed` and :cmd:`Save`, except the proof is made *transparent*, which means
+ that its content can be explicitly used for type checking and that it can be
+ unfolded in conversion tactics (see :ref:`performingcomputations`,
+ :cmd:`Opaque`, :cmd:`Transparent`). If :token:`ident` is specified,
+ the proof is defined with the given name, which overrides any name
+ provided by the :cmd:`Theorem` command or its variants.
+
+.. cmd:: Admitted
+
+ This command is available in interactive editing mode to give up
+ the current proof and declare the initial goal as an axiom.
+
+.. cmd:: Abort {? {| All | @ident } }
+
+ Cancels the current proof development, switching back to
+ the previous proof development, or to the |Coq| toplevel if no other
+ proof was being edited.
+
+ :n:`@ident`
+ Aborts editing the proof named :n:`@ident` for use when you have
+ nested proofs. See also :flag:`Nested Proofs Allowed`.
+
+ :n:`All`
+ Aborts all current proofs.
+
+ .. exn:: No focused proof (No proof-editing in progress).
+ :undocumented:
+
+.. cmd:: Proof @term
+ :name: Proof `term`
+
+ This command applies in proof editing mode. It is equivalent to
+ :n:`exact @term. Qed.`
+ That is, you have to give the full proof in one gulp, as a
+ proof term (see Section :ref:`applyingtheorems`).
+
+ .. warning::
+
+ Use of this command is discouraged. In particular, it
+ doesn't work in Proof General because it must
+ immediately follow the command that opened proof mode, but
+ Proof General inserts :cmd:`Unset` :flag:`Silent` before it (see
+ `Proof General issue #498
+ <https://github.com/ProofGeneral/PG/issues/498>`_).
+
+.. cmd:: Proof
+
+ Is a no-op which is useful to delimit the sequence of tactic commands
+ which start a proof, after a :cmd:`Theorem` command. It is a good practice to
+ use :cmd:`Proof` as an opening parenthesis, closed in the script with a
+ closing :cmd:`Qed`.
+
+ .. seealso:: :cmd:`Proof with`
+
+.. cmd:: Proof using @section_var_expr {? with @ltac_expr }
+
+ .. insertprodn section_var_expr starred_ident_ref
+
+ .. prodn::
+ section_var_expr ::= {* @starred_ident_ref }
+ | {? - } @section_var_expr50
+ section_var_expr50 ::= @section_var_expr0 - @section_var_expr0
+ | @section_var_expr0 + @section_var_expr0
+ | @section_var_expr0
+ section_var_expr0 ::= @starred_ident_ref
+ | ( @section_var_expr ) {? * }
+ starred_ident_ref ::= @ident {? * }
+ | Type {? * }
+ | All
+
+ Opens proof editing mode, declaring the set of
+ section variables (see :ref:`gallina-assumptions`) used by the proof.
+ At :cmd:`Qed` time, the
+ system verifies that the set of section variables used in
+ the proof is a subset of the declared one.
+
+ The set of declared variables is closed under type dependency. For
+ example, if ``T`` is a variable and ``a`` is a variable of type
+ ``T``, then the commands ``Proof using a`` and ``Proof using T a``
+ are equivalent.
+
+ The set of declared variables always includes the variables used by
+ the statement. In other words ``Proof using e`` is equivalent to
+ ``Proof using Type + e`` for any declaration expression ``e``.
+
+ :n:`- @section_var_expr50`
+ Use all section variables except those specified by :n:`@section_var_expr50`
+
+ :n:`@section_var_expr0 + @section_var_expr0`
+ Use section variables from the union of both collections.
+ See :ref:`nameaset` to see how to form a named collection.
+
+ :n:`@section_var_expr0 - @section_var_expr0`
+ Use section variables which are in the first collection but not in the
+ second one.
+
+ :n:`{? * }`
+ Use the transitive closure of the specified collection.
+
+ :n:`Type`
+ Use only section variables occurring in the statement. Specifying :n:`*`
+ uses the forward transitive closure of all the section variables occurring
+ in the statement. For example, if the variable ``H`` has type ``p < 5`` then
+ ``H`` is in ``p*`` since ``p`` occurs in the type of ``H``.
+
+ :n:`All`
+ Use all section variables.
+
+ .. seealso:: :ref:`tactics-implicit-automation`
+
+.. attr:: using
+
+ This attribute can be applied to the :cmd:`Definition`, :cmd:`Example`,
+ :cmd:`Fixpoint` and :cmd:`CoFixpoint` commands as well as to :cmd:`Lemma` and
+ its variants. It takes
+ a :n:`@section_var_expr`, in quotes, as its value. This is equivalent to
+ specifying the same :n:`@section_var_expr` in
+ :cmd:`Proof using`.
+
+ .. example::
+
+ .. coqtop:: all
+
+ Section Test.
+ Variable n : nat.
+ Hypothesis Hn : n <> 0.
+
+ #[using="Hn"]
+ Lemma example : 0 < n.
+
+ .. coqtop:: in
+
+ Abort.
+ End Test.
+
+
+Proof using options
+```````````````````
+
+The following options modify the behavior of ``Proof using``.
+
+
+.. opt:: Default Proof Using "@section_var_expr"
+ :name: Default Proof Using
+
+ Use :n:`@section_var_expr` as the default ``Proof using`` value. E.g. ``Set Default
+ Proof Using "a b"`` will complete all ``Proof`` commands not followed by a
+ ``using`` part with ``using a b``.
+
+
+.. flag:: Suggest Proof Using
+
+ When :cmd:`Qed` is performed, suggest a ``using`` annotation if the user did not
+ provide one.
+
+.. _`nameaset`:
+
+Name a set of section hypotheses for ``Proof using``
+````````````````````````````````````````````````````
+
+.. cmd:: Collection @ident := @section_var_expr
+
+ This can be used to name a set of section
+ hypotheses, with the purpose of making ``Proof using`` annotations more
+ compact.
+
+ .. example::
+
+ Define the collection named ``Some`` containing ``x``, ``y`` and ``z``::
+
+ Collection Some := x y z.
+
+ Define the collection named ``Fewer`` containing only ``x`` and ``y``::
+
+ Collection Fewer := Some - z
+
+ Define the collection named ``Many`` containing the set union or set
+ difference of ``Fewer`` and ``Some``::
+
+ Collection Many := Fewer + Some
+ Collection Many := Fewer - Some
+
+ Define the collection named ``Many`` containing the set difference of
+ ``Fewer`` and the unnamed collection ``x y``::
+
+ Collection Many := Fewer - (x y)
+
+
+
+.. cmd:: Existential @natural {? : @type } := @term
+
+ This command instantiates an existential variable. :token:`natural` is an index in
+ the list of uninstantiated existential variables displayed by :cmd:`Show Existentials`.
+
+ This command is intended to be used to instantiate existential
+ variables when the proof is completed but some uninstantiated
+ existential variables remain. To instantiate existential variables
+ during proof edition, you should use the tactic :tacn:`instantiate`.
+
+.. cmd:: Grab Existential Variables
+
+ This command can be run when a proof has no more goal to be solved but
+ has remaining uninstantiated existential variables. It takes every
+ uninstantiated existential variable and turns it into a goal.
+
+Proof modes
+```````````
+
+When entering proof mode through commands such as :cmd:`Goal` and :cmd:`Proof`,
+|Coq| picks by default the |Ltac| mode. Nonetheless, there exist other proof modes
+shipped in the standard |Coq| installation, and furthermore some plugins define
+their own proof modes. The default proof mode used when opening a proof can
+be changed using the following option.
+
+.. opt:: Default Proof Mode @string
+
+ Select the proof mode to use when starting a proof. Depending on the proof
+ mode, various syntactic constructs are allowed when writing an interactive
+ proof. All proof modes support vernacular commands; the proof mode determines
+ which tactic language and set of tactic definitions are available. The
+ possible option values are:
+
+ `"Classic"`
+ Activates the |Ltac| language and the tactics with the syntax documented
+ in this manual.
+ Some tactics are not available until the associated plugin is loaded,
+ such as `SSR` or `micromega`.
+ This proof mode is set when the :term:`prelude` is loaded.
+
+ `"Noedit"`
+ No tactic
+ language is activated at all. This is the default when the :term:`prelude`
+ is not loaded, e.g. through the `-noinit` option for `coqc`.
+
+ `"Ltac2"`
+ Activates the Ltac2 language and the Ltac2-specific variants of the documented
+ tactics.
+ This value is only available after :cmd:`Requiring <Require>` Ltac2.
+ :cmd:`Importing <Import>` Ltac2 sets this mode.
+
+ Some external plugins also define their own proof mode, which can be
+ activated with this command.
+
+Navigation in the proof tree
+--------------------------------
+
+.. cmd:: Undo {? {? To } @natural }
+
+ Cancels the effect of the last :token:`natural` commands or tactics.
+ The :n:`To @natural` form goes back to the specified state number.
+ If :token:`natural` is not specified, the command goes back one command or tactic.
+
+.. cmd:: Restart
+
+ Restores the proof editing process to the original goal.
+
+ .. exn:: No focused proof to restart.
+ :undocumented:
+
+.. cmd:: Focus {? @natural }
+
+ Focuses the attention on the first subgoal to prove or, if :token:`natural` is
+ specified, the :token:`natural`\-th. The
+ printing of the other subgoals is suspended until the focused subgoal
+ is solved or unfocused.
+
+ .. deprecated:: 8.8
+
+ Prefer the use of bullets or focusing brackets with a goal selector (see below).
+
+.. cmd:: Unfocus
+
+ This command restores to focus the goal that were suspended by the
+ last :cmd:`Focus` command.
+
+ .. deprecated:: 8.8
+
+.. cmd:: Unfocused
+
+ Succeeds if the proof is fully unfocused, fails if there are some
+ goals out of focus.
+
+.. _curly-braces:
+
+.. index:: {
+ }
+
+.. todo: :name: "{"; "}" doesn't work, nor does :name: left curly bracket; right curly bracket,
+ hence the verbose names
+
+.. tacn:: {? {| @natural | [ @ident ] } : } %{
+ %}
+
+ .. todo
+ See https://github.com/coq/coq/issues/12004 and
+ https://github.com/coq/coq/issues/12825.
+
+ ``{`` (without a terminating period) focuses on the first
+ goal. The subproof can only be
+ unfocused when it has been fully solved (*i.e.*, when there is no
+ focused goal left). Unfocusing is then handled by ``}`` (again, without a
+ terminating period). See also an example in the next section.
+
+ Note that when a focused goal is proved a message is displayed
+ together with a suggestion about the right bullet or ``}`` to unfocus it
+ or focus the next one.
+
+ :n:`@natural:`
+ Focuses on the :token:`natural`\-th subgoal to prove.
+
+ :n:`[ @ident ]: %{`
+ Focuses on the named goal :token:`ident`.
+
+ .. note::
+
+ Goals are just existential variables and existential variables do not
+ get a name by default. You can give a name to a goal by using :n:`refine ?[@ident]`.
+ You may also wrap this in an Ltac-definition like:
+
+ .. coqtop:: in
+
+ Ltac name_goal name := refine ?[name].
+
+ .. seealso:: :ref:`existential-variables`
+
+ .. example::
+
+ This first example uses the Ltac definition above, and the named goals
+ only serve for documentation.
+
+ .. coqtop:: all
+
+ Goal forall n, n + 0 = n.
+ Proof.
+ induction n; [ name_goal base | name_goal step ].
+ [base]: {
+
+ .. coqtop:: all
+
+ reflexivity.
+
+ .. coqtop:: in
+
+ }
+
+ .. coqtop:: all
+
+ [step]: {
+
+ .. coqtop:: all
+
+ simpl.
+ f_equal.
+ assumption.
+ }
+ Qed.
+
+ This can also be a way of focusing on a shelved goal, for instance:
+
+ .. coqtop:: all
+
+ Goal exists n : nat, n = n.
+ eexists ?[x].
+ reflexivity.
+ [x]: exact 0.
+ Qed.
+
+ .. exn:: This proof is focused, but cannot be unfocused this way.
+
+ You are trying to use ``}`` but the current subproof has not been fully solved.
+
+ .. exn:: No such goal (@natural).
+ :undocumented:
+
+ .. exn:: No such goal (@ident).
+ :undocumented:
+
+ .. exn:: Brackets do not support multi-goal selectors.
+
+ Brackets are used to focus on a single goal given either by its position
+ or by its name if it has one.
+
+ .. seealso:: The error messages for bullets below.
+
+.. _bullets:
+
+Bullets
+```````
+
+Alternatively, proofs can be structured with bullets instead of ``{`` and ``}``. The
+use of a bullet ``b`` for the first time focuses on the first goal ``g``, the
+same bullet cannot be used again until the proof of ``g`` is completed,
+then it is mandatory to focus the next goal with ``b``. The consequence is
+that ``g`` and all goals present when ``g`` was focused are focused with the
+same bullet ``b``. See the example below.
+
+Different bullets can be used to nest levels. The scope of bullet does
+not go beyond enclosing ``{`` and ``}``, so bullets can be reused as further
+nesting levels provided they are delimited by these. Bullets are made of
+repeated ``-``, ``+`` or ``*`` symbols:
+
+.. prodn:: bullet ::= {| {+ - } | {+ + } | {+ * } }
+
+Note again that when a focused goal is proved a message is displayed
+together with a suggestion about the right bullet or ``}`` to unfocus it
+or focus the next one.
+
+.. note::
+
+ In Proof General (``Emacs`` interface to |Coq|), you must use
+ bullets with the priority ordering shown above to have a correct
+ indentation. For example ``-`` must be the outer bullet and ``**`` the inner
+ one in the example below.
+
+The following example script illustrates all these features:
+
+.. example::
+
+ .. coqtop:: all
+
+ Goal (((True /\ True) /\ True) /\ True) /\ True.
+ Proof.
+ split.
+ - split.
+ + split.
+ ** { split.
+ - trivial.
+ - trivial.
+ }
+ ** trivial.
+ + trivial.
+ - assert True.
+ { trivial. }
+ assumption.
+ Qed.
+
+.. exn:: Wrong bullet @bullet__1: Current bullet @bullet__2 is not finished.
+
+ Before using bullet :n:`@bullet__1` again, you should first finish proving
+ the current focused goal.
+ Note that :n:`@bullet__1` and :n:`@bullet__2` may be the same.
+
+.. exn:: Wrong bullet @bullet__1: Bullet @bullet__2 is mandatory here.
+
+ You must put :n:`@bullet__2` to focus on the next goal. No other bullet is
+ allowed here.
+
+.. exn:: No such goal. Focus next goal with bullet @bullet.
+
+ You tried to apply a tactic but no goals were under focus.
+ Using :n:`@bullet` is mandatory here.
+
+.. FIXME: the :noindex: below works around a Sphinx issue.
+ (https://github.com/sphinx-doc/sphinx/issues/4979)
+ It should be removed once that issue is fixed.
+
+.. exn:: No such goal. Try unfocusing with %}.
+ :noindex:
+
+ You just finished a goal focused by ``{``, you must unfocus it with ``}``.
+
+Mandatory Bullets
+~~~~~~~~~~~~~~~~~
+
+Using :opt:`Default Goal Selector` with the ``!`` selector forces
+tactic scripts to keep focus to exactly one goal (e.g. using bullets)
+or use explicit goal selectors.
+
+Set Bullet Behavior
+~~~~~~~~~~~~~~~~~~~
+
+.. opt:: Bullet Behavior {| "None" | "Strict Subproofs" }
+ :name: Bullet Behavior
+
+ This option controls the bullet behavior and can take two possible values:
+
+ - "None": this makes bullets inactive.
+ - "Strict Subproofs": this makes bullets active (this is the default behavior).
+
+Modifying the order of goals
+````````````````````````````
+
+.. tacn:: cycle @integer
+ :name: cycle
+
+ Reorders the selected goals so that the first :n:`@integer` goals appear after the
+ other selected goals.
+ If :n:`@integer` is negative, it puts the last :n:`@integer` goals at the
+ beginning of the list.
+ The tactic is only useful with a goal selector, most commonly `all:`.
+ Note that other selectors reorder goals; `1,3: cycle 1` is not equivalent
+ to `all: cycle 1`. See :tacn:`… : … (goal selector)`.
+
+.. example::
+
+ .. coqtop:: none reset
+
+ Parameter P : nat -> Prop.
+
+ .. coqtop:: all abort
+
+ Goal P 1 /\ P 2 /\ P 3 /\ P 4 /\ P 5.
+ repeat split.
+ all: cycle 2.
+ all: cycle -3.
+
+.. tacn:: swap @integer @integer
+ :name: swap
+
+ Exchanges the position of the specified goals.
+ Negative values for :n:`@integer` indicate counting goals
+ backward from the end of the list of selected goals. Goals are indexed from 1.
+ The tactic is only useful with a goal selector, most commonly `all:`.
+ Note that other selectors reorder goals; `1,3: swap 1 3` is not equivalent
+ to `all: swap 1 3`. See :tacn:`… : … (goal selector)`.
+
+.. example::
+
+ .. coqtop:: all abort
+
+ Goal P 1 /\ P 2 /\ P 3 /\ P 4 /\ P 5.
+ repeat split.
+ all: swap 1 3.
+ all: swap 1 -1.
+
+.. tacn:: revgoals
+ :name: revgoals
+
+ Reverses the order of the selected goals. The tactic is only useful with a goal
+ selector, most commonly `all :`. Note that other selectors reorder goals;
+ `1,3: revgoals` is not equivalent to `all: revgoals`. See :tacn:`… : … (goal selector)`.
+
+ .. example::
+
+ .. coqtop:: all abort
+
+ Goal P 1 /\ P 2 /\ P 3 /\ P 4 /\ P 5.
+ repeat split.
+ all: revgoals.
+
+Postponing the proof of some goals
+``````````````````````````````````
+
+.. tacn:: shelve
+ :name: shelve
+
+ This tactic moves all goals under focus to a shelf. While on the
+ shelf, goals will not be focused on. They can be solved by
+ unification, or they can be called back into focus with the command
+ :cmd:`Unshelve`.
+
+ .. tacv:: shelve_unifiable
+ :name: shelve_unifiable
+
+ Shelves only the goals under focus that are mentioned in other goals.
+ Goals that appear in the type of other goals can be solved by unification.
+
+ .. example::
+
+ .. coqtop:: all abort
+
+ Goal exists n, n=0.
+ refine (ex_intro _ _ _).
+ all: shelve_unifiable.
+ reflexivity.
+
+.. cmd:: Unshelve
+
+ This command moves all the goals on the shelf (see :tacn:`shelve`)
+ from the shelf into focus, by appending them to the end of the current
+ list of focused goals.
+
+.. tacn:: unshelve @tactic
+ :name: unshelve
+
+ Performs :n:`@tactic`, then unshelves existential variables added to the
+ shelf by the execution of :n:`@tactic`, prepending them to the current goal.
+
+.. tacn:: give_up
+ :name: give_up
+
+ This tactic removes the focused goals from the proof. They are not
+ solved, and cannot be solved later in the proof. As the goals are not
+ solved, the proof cannot be closed.
+
+ The ``give_up`` tactic can be used while editing a proof, to choose to
+ write the proof script in a non-sequential order.
+
+.. _requestinginformation:
+
+Requesting information
+----------------------
+
+
+.. cmd:: Show {? {| @ident | @natural } }
+
+ Displays the current goals.
+
+ :n:`@natural`
+ Display only the :token:`natural`\-th subgoal.
+
+ :n:`@ident`
+ Displays the named goal :token:`ident`. This is useful in
+ particular to display a shelved goal but only works if the
+ corresponding existential variable has been named by the user
+ (see :ref:`existential-variables`) as in the following example.
+
+ .. example::
+
+ .. coqtop:: all abort
+
+ Goal exists n, n = 0.
+ eexists ?[n].
+ Show n.
+
+ .. exn:: No focused proof.
+ :undocumented:
+
+ .. exn:: No such goal.
+ :undocumented:
+
+.. cmd:: Show Proof {? Diffs {? removed } }
+
+ Displays the proof term generated by the tactics
+ that have been applied so far. If the proof is incomplete, the term
+ will contain holes, which correspond to subterms which are still to be
+ constructed. Each hole is an existential variable, which appears as a
+ question mark followed by an identifier.
+
+ Specifying “Diffs” highlights the difference between the
+ current and previous proof step. By default, the command shows the
+ output once with additions highlighted. Including “removed” shows
+ the output twice: once showing removals and once showing additions.
+ It does not examine the :opt:`Diffs` option. See :ref:`showing_proof_diffs`.
+
+.. cmd:: Show Conjectures
+
+ Prints the names of all the
+ theorems that are currently being proved. As it is possible to start
+ proving a previous lemma during the proof of a theorem, there may
+ be multiple names.
+
+.. cmd:: Show Intro
+
+ If the current goal begins by at least one product,
+ prints the name of the first product as it would be
+ generated by an anonymous :tacn:`intro`. The aim of this command is to ease
+ the writing of more robust scripts. For example, with an appropriate
+ Proof General macro, it is possible to transform any anonymous :tacn:`intro`
+ into a qualified one such as ``intro y13``. In the case of a non-product
+ goal, it prints nothing.
+
+.. cmd:: Show Intros
+
+ Similar to the previous command.
+ Simulates the naming process of :tacn:`intros`.
+
+.. cmd:: Show Existentials
+
+ Displays all open goals / existential variables in the current proof
+ along with the type and the context of each variable.
+
+.. cmd:: Show Match @qualid
+
+ Displays a template of the Gallina :token:`match<term_match>`
+ construct with a branch for each constructor of the type
+ :token:`qualid`. This is used internally by
+ `company-coq <https://github.com/cpitclaudel/company-coq>`_.
+
+ .. example::
+
+ .. coqtop:: all
+
+ Show Match nat.
+
+ .. exn:: Unknown inductive type.
+ :undocumented:
+
+.. cmd:: Show Universes
+
+ Displays the set of all universe constraints and
+ its normalized form at the current stage of the proof, useful for
+ debugging universe inconsistencies.
+
+.. cmd:: Show Goal @natural at @natural
+
+ Available in coqtop. Displays a goal at a
+ proof state using the goal ID number and the proof state ID number.
+ It is primarily for use by tools such as Prooftree that need to fetch
+ goal history in this way. Prooftree is a tool for visualizing a proof
+ as a tree that runs in Proof General.
+
+.. cmd:: Guarded
+
+ Some tactics (e.g. :tacn:`refine`) allow to build proofs using
+ fixpoint or co-fixpoint constructions. Due to the incremental nature
+ of interactive proof construction, the check of the termination (or
+ guardedness) of the recursive calls in the fixpoint or cofixpoint
+ constructions is postponed to the time of the completion of the proof.
+
+ The command :cmd:`Guarded` allows checking if the guard condition for
+ fixpoint and cofixpoint is violated at some time of the construction
+ of the proof without having to wait the completion of the proof.
+
+.. _showing_diffs:
+
+Showing differences between proof steps
+---------------------------------------
+
+|Coq| can automatically highlight the differences between successive proof steps
+and between values in some error messages. |Coq| can also highlight differences
+in the proof term.
+For example, the following screenshots of |CoqIDE| and coqtop show the application
+of the same :tacn:`intros` tactic. The tactic creates two new hypotheses, highlighted in green.
+The conclusion is entirely in pale green because although it’s changed, no tokens were added
+to it. The second screenshot uses the "removed" option, so it shows the conclusion a
+second time with the old text, with deletions marked in red. Also, since the hypotheses are
+new, no line of old text is shown for them.
+
+.. comment screenshot produced with:
+ Inductive ev : nat -> Prop :=
+ | ev_0 : ev 0
+ | ev_SS : forall n : nat, ev n -> ev (S (S n)).
+
+ Fixpoint double (n:nat) :=
+ match n with
+ | O => O
+ | S n' => S (S (double n'))
+ end.
+
+ Goal forall n, ev n -> exists k, n = double k.
+ intros n E.
+
+..
+
+ .. image:: ../../_static/diffs-coqide-on.png
+ :alt: |CoqIDE| with Set Diffs on
+
+..
+
+ .. image:: ../../_static/diffs-coqide-removed.png
+ :alt: |CoqIDE| with Set Diffs removed
+
+..
+
+ .. image:: ../../_static/diffs-coqtop-on3.png
+ :alt: coqtop with Set Diffs on
+
+This image shows an error message with diff highlighting in |CoqIDE|:
+
+..
+
+ .. image:: ../../_static/diffs-error-message.png
+ :alt: |CoqIDE| error message with diffs
+
+How to enable diffs
+```````````````````
+
+.. opt:: Diffs {| "on" | "off" | "removed" }
+ :name: Diffs
+
+ The “on” setting highlights added tokens in green, while the “removed” setting
+ additionally reprints items with removed tokens in red. Unchanged tokens in
+ modified items are shown with pale green or red. Diffs in error messages
+ use red and green for the compared values; they appear regardless of the setting.
+ (Colors are user-configurable.)
+
+For coqtop, showing diffs can be enabled when starting coqtop with the
+``-diffs on|off|removed`` command-line option or by setting the :opt:`Diffs` option
+within |Coq|. You will need to provide the ``-color on|auto`` command-line option when
+you start coqtop in either case.
+
+Colors for coqtop can be configured by setting the ``COQ_COLORS`` environment
+variable. See section :ref:`customization-by-environment-variables`. Diffs
+use the tags ``diff.added``, ``diff.added.bg``, ``diff.removed`` and ``diff.removed.bg``.
+
+In |CoqIDE|, diffs should be enabled from the ``View`` menu. Don’t use the ``Set Diffs``
+command in |CoqIDE|. You can change the background colors shown for diffs from the
+``Edit | Preferences | Tags`` panel by changing the settings for the ``diff.added``,
+``diff.added.bg``, ``diff.removed`` and ``diff.removed.bg`` tags. This panel also
+lets you control other attributes of the highlights, such as the foreground
+color, bold, italic, underline and strikeout.
+
+Proof General can also display |Coq|-generated proof diffs automatically.
+Please see the PG documentation section
+"`Showing Proof Diffs" <https://proofgeneral.github.io/doc/master/userman/Coq-Proof-General#Showing-Proof-Diffs>`_)
+for details.
+
+How diffs are calculated
+````````````````````````
+
+Diffs are calculated as follows:
+
+1. Select the old proof state to compare to, which is the proof state before
+ the last tactic that changed the proof. Changes that only affect the view
+ of the proof, such as ``all: swap 1 2``, are ignored.
+
+2. For each goal in the new proof state, determine what old goal to compare
+ it to—the one it is derived from or is the same as. Match the hypotheses by
+ name (order is ignored), handling compacted items specially.
+
+3. For each hypothesis and conclusion (the “items”) in each goal, pass
+ them as strings to the lexer to break them into tokens. Then apply the
+ Myers diff algorithm :cite:`Myers` on the tokens and add appropriate highlighting.
+
+Notes:
+
+* Aside from the highlights, output for the "on" option should be identical
+ to the undiffed output.
+* Goals completed in the last proof step will not be shown even with the
+ "removed" setting.
+
+.. comment The following screenshots show diffs working with multiple goals and with compacted
+ hypotheses. In the first one, notice that the goal ``P 1`` is not highlighted at
+ all after the split because it has not changed.
+
+ .. todo: Use this script and remove the screenshots when COQ_COLORS
+ works for coqtop in sphinx
+ .. coqtop:: none
+
+ Set Diffs "on".
+ Parameter P : nat -> Prop.
+ Goal P 1 /\ P 2 /\ P 3.
+
+ .. coqtop:: out
+
+ split.
+
+ .. coqtop:: all abort
+
+ 2: split.
+
+ ..
+
+ .. coqtop:: none
+
+ Set Diffs "on".
+ Goal forall n m : nat, n + m = m + n.
+ Set Diffs "on".
+
+ .. coqtop:: out
+
+ intros n.
+
+ .. coqtop:: all abort
+
+ intros m.
+
+This screen shot shows the result of applying a :tacn:`split` tactic that replaces one goal
+with 2 goals. Notice that the goal ``P 1`` is not highlighted at all after
+the split because it has not changed.
+
+..
+
+ .. image:: ../../_static/diffs-coqide-multigoal.png
+ :alt: coqide with Set Diffs on with multiple goals
+
+Diffs may appear like this after applying a :tacn:`intro` tactic that results
+in a compacted hypotheses:
+
+..
+
+ .. image:: ../../_static/diffs-coqide-compacted.png
+ :alt: coqide with Set Diffs on with compacted hypotheses
+
+.. _showing_proof_diffs:
+
+"Show Proof" differences
+````````````````````````
+
+To show differences in the proof term:
+
+- In coqtop and Proof General, use the :cmd:`Show Proof` `Diffs` command.
+
+- In |CoqIDE|, position the cursor on or just after a tactic to compare the proof term
+ after the tactic with the proof term before the tactic, then select
+ `View / Show Proof` from the menu or enter the associated key binding.
+ Differences will be shown applying the current `Show Diffs` setting
+ from the `View` menu. If the current setting is `Don't show diffs`, diffs
+ will not be shown.
+
+ Output with the "added and removed" option looks like this:
+
+ ..
+
+ .. image:: ../../_static/diffs-show-proof.png
+ :alt: coqide with Set Diffs on with compacted hypotheses
+
+Controlling the effect of proof editing commands
+------------------------------------------------
+
+
+.. opt:: Hyps Limit @natural
+ :name: Hyps Limit
+
+ This option controls the maximum number of hypotheses displayed in goals
+ after the application of a tactic. All the hypotheses remain usable
+ in the proof development.
+ When unset, it goes back to the default mode which is to print all
+ available hypotheses.
+
+
+.. flag:: Nested Proofs Allowed
+
+ When turned on (it is off by default), this flag enables support for nested
+ proofs: a new assertion command can be inserted before the current proof is
+ finished, in which case |Coq| will temporarily switch to the proof of this
+ *nested lemma*. When the proof of the nested lemma is finished (with :cmd:`Qed`
+ or :cmd:`Defined`), its statement will be made available (as if it had been
+ proved before starting the previous proof) and |Coq| will switch back to the
+ proof of the previous assertion.
+
+.. flag:: Printing Goal Names
+
+ When turned on, the name of the goal is printed in interactive
+ proof mode, which can be useful in cases of cross references
+ between goals.
+
+Controlling memory usage
+------------------------
+
+.. cmd:: Print Debug GC
+
+ Prints heap usage statistics, which are values from the `stat` type of the `Gc` module
+ described
+ `here <https://caml.inria.fr/pub/docs/manual-ocaml/libref/Gc.html#TYPEstat>`_
+ in the |OCaml| documentation.
+ The `live_words`, `heap_words` and `top_heap_words` values give the basic information.
+ Words are 8 bytes or 4 bytes, respectively, for 64- and 32-bit executables.
+
+When experiencing high memory usage the following commands can be used
+to force |Coq| to optimize some of its internal data structures.
+
+.. cmd:: Optimize Proof
+
+ Shrink the data structure used to represent the current proof.
+
+
+.. cmd:: Optimize Heap
+
+ Perform a heap compaction. This is generally an expensive operation.
+ See: `|OCaml| Gc.compact <http://caml.inria.fr/pub/docs/manual-ocaml/libref/Gc.html#VALcompact>`_
+ There is also an analogous tactic :tacn:`optimize_heap`.
+
+Memory usage parameters can be set through the :ref:`OCAMLRUNPARAM <OCAMLRUNPARAM>`
+environment variable.
diff --git a/doc/sphinx/proofs/writing-proofs/rewriting.rst b/doc/sphinx/proofs/writing-proofs/rewriting.rst
new file mode 100644
index 0000000000..1358aad432
--- /dev/null
+++ b/doc/sphinx/proofs/writing-proofs/rewriting.rst
@@ -0,0 +1,857 @@
+=================================
+Term rewriting and simplification
+=================================
+
+.. _rewritingexpressions:
+
+Rewriting expressions
+---------------------
+
+These tactics use the equality :g:`eq:forall A:Type, A->A->Prop` defined in
+file ``Logic.v`` (see :ref:`coq-library-logic`). The notation for :g:`eq T t u` is
+simply :g:`t=u` dropping the implicit type of :g:`t` and :g:`u`.
+
+.. tacn:: rewrite @term
+ :name: rewrite
+
+ This tactic applies to any goal. The type of :token:`term` must have the form
+
+ ``forall (x``:sub:`1` ``:A``:sub:`1` ``) ... (x``:sub:`n` ``:A``:sub:`n` ``), eq term``:sub:`1` ``term``:sub:`2` ``.``
+
+ where :g:`eq` is the Leibniz equality or a registered setoid equality.
+
+ Then :n:`rewrite @term` finds the first subterm matching `term`\ :sub:`1` in the goal,
+ resulting in instances `term`:sub:`1`' and `term`:sub:`2`' and then
+ replaces every occurrence of `term`:subscript:`1`' by `term`:subscript:`2`'.
+ Hence, some of the variables :g:`x`\ :sub:`i` are solved by unification,
+ and some of the types :g:`A`\ :sub:`1`:g:`, ..., A`\ :sub:`n` become new
+ subgoals.
+
+ .. exn:: The @term provided does not end with an equation.
+ :undocumented:
+
+ .. exn:: Tactic generated a subgoal identical to the original goal. This happens if @term does not occur in the goal.
+ :undocumented:
+
+ .. tacv:: rewrite -> @term
+
+ Is equivalent to :n:`rewrite @term`
+
+ .. tacv:: rewrite <- @term
+
+ Uses the equality :n:`@term`:sub:`1` :n:`= @term` :sub:`2` from right to left
+
+ .. tacv:: rewrite @term in @goal_occurrences
+
+ Analogous to :n:`rewrite @term` but rewriting is done following
+ the clause :token:`goal_occurrences`. For instance:
+
+ + :n:`rewrite H in H'` will rewrite `H` in the hypothesis
+ ``H'`` instead of the current goal.
+ + :n:`rewrite H in H' at 1, H'' at - 2 |- *` means
+ :n:`rewrite H; rewrite H in H' at 1; rewrite H in H'' at - 2.`
+ In particular a failure will happen if any of these three simpler tactics
+ fails.
+ + :n:`rewrite H in * |-` will do :n:`rewrite H in H'` for all hypotheses
+ :g:`H'` different from :g:`H`.
+ A success will happen as soon as at least one of these simpler tactics succeeds.
+ + :n:`rewrite H in *` is a combination of :n:`rewrite H` and :n:`rewrite H in * |-`
+ that succeeds if at least one of these two tactics succeeds.
+
+ Orientation :g:`->` or :g:`<-` can be inserted before the :token:`term` to rewrite.
+
+ .. tacv:: rewrite @term at @occurrences
+
+ Rewrite only the given :token:`occurrences` of :token:`term`. Occurrences are
+ specified from left to right as for pattern (:tacn:`pattern`). The rewrite is
+ always performed using setoid rewriting, even for Leibniz’s equality, so one
+ has to ``Import Setoid`` to use this variant.
+
+ .. tacv:: rewrite @term by @tactic
+
+ Use tactic to completely solve the side-conditions arising from the
+ :tacn:`rewrite`.
+
+ .. tacv:: rewrite {+, @orientation @term} {? in @ident }
+
+ Is equivalent to the `n` successive tactics :n:`{+; rewrite @term}`, each one
+ working on the first subgoal generated by the previous one. An :production:`orientation`
+ ``->`` or ``<-`` can be inserted before each :token:`term` to rewrite. One
+ unique clause can be added at the end after the keyword in; it will then
+ affect all rewrite operations.
+
+ In all forms of rewrite described above, a :token:`term` to rewrite can be
+ immediately prefixed by one of the following modifiers:
+
+ + `?` : the tactic :n:`rewrite ?@term` performs the rewrite of :token:`term` as many
+ times as possible (perhaps zero time). This form never fails.
+ + :n:`@natural?` : works similarly, except that it will do at most :token:`natural` rewrites.
+ + `!` : works as `?`, except that at least one rewrite should succeed, otherwise
+ the tactic fails.
+ + :n:`@natural!` (or simply :n:`@natural`) : precisely :token:`natural` rewrites of :token:`term` will be done,
+ leading to failure if these :token:`natural` rewrites are not possible.
+
+ .. tacv:: erewrite @term
+ :name: erewrite
+
+ This tactic works as :n:`rewrite @term` but turning
+ unresolved bindings into existential variables, if any, instead of
+ failing. It has the same variants as :tacn:`rewrite` has.
+
+ .. flag:: Keyed Unification
+
+ Makes higher-order unification used by :tacn:`rewrite` rely on a set of keys to drive
+ unification. The subterms, considered as rewriting candidates, must start with
+ the same key as the left- or right-hand side of the lemma given to rewrite, and the arguments
+ are then unified up to full reduction.
+
+.. tacn:: replace @term with @term’
+ :name: replace
+
+ This tactic applies to any goal. It replaces all free occurrences of :n:`@term`
+ in the current goal with :n:`@term’` and generates an equality :n:`@term = @term’`
+ as a subgoal. This equality is automatically solved if it occurs among
+ the assumptions, or if its symmetric form occurs. It is equivalent to
+ :n:`cut @term = @term’; [intro H`:sub:`n` :n:`; rewrite <- H`:sub:`n` :n:`; clear H`:sub:`n`:n:`|| assumption || symmetry; try assumption]`.
+
+ .. exn:: Terms do not have convertible types.
+ :undocumented:
+
+ .. tacv:: replace @term with @term’ by @tactic
+
+ This acts as :n:`replace @term with @term’` but applies :token:`tactic` to solve the generated
+ subgoal :n:`@term = @term’`.
+
+ .. tacv:: replace @term
+
+ Replaces :n:`@term` with :n:`@term’` using the first assumption whose type has
+ the form :n:`@term = @term’` or :n:`@term’ = @term`.
+
+ .. tacv:: replace -> @term
+
+ Replaces :n:`@term` with :n:`@term’` using the first assumption whose type has
+ the form :n:`@term = @term’`
+
+ .. tacv:: replace <- @term
+
+ Replaces :n:`@term` with :n:`@term’` using the first assumption whose type has
+ the form :n:`@term’ = @term`
+
+ .. tacv:: replace @term {? with @term} in @goal_occurrences {? by @tactic}
+ replace -> @term in @goal_occurrences
+ replace <- @term in @goal_occurrences
+
+ Acts as before but the replacements take place in the specified clauses
+ (:token:`goal_occurrences`) (see :ref:`performingcomputations`) and not
+ only in the conclusion of the goal. The clause argument must not contain
+ any ``type of`` nor ``value of``.
+
+.. tacn:: subst @ident
+ :name: subst
+
+ This tactic applies to a goal that has :n:`@ident` in its context and (at
+ least) one hypothesis, say :g:`H`, of type :n:`@ident = t` or :n:`t = @ident`
+ with :n:`@ident` not occurring in :g:`t`. Then it replaces :n:`@ident` by
+ :g:`t` everywhere in the goal (in the hypotheses and in the conclusion) and
+ clears :n:`@ident` and :g:`H` from the context.
+
+ If :n:`@ident` is a local definition of the form :n:`@ident := t`, it is also
+ unfolded and cleared.
+
+ If :n:`@ident` is a section variable it is expected to have no
+ indirect occurrences in the goal, i.e. that no global declarations
+ implicitly depending on the section variable must be present in the
+ goal.
+
+ .. note::
+ + When several hypotheses have the form :n:`@ident = t` or :n:`t = @ident`, the
+ first one is used.
+
+ + If :g:`H` is itself dependent in the goal, it is replaced by the proof of
+ reflexivity of equality.
+
+ .. tacv:: subst {+ @ident}
+
+ This is equivalent to :n:`subst @ident`:sub:`1`:n:`; ...; subst @ident`:sub:`n`.
+
+ .. tacv:: subst
+
+ This applies :tacn:`subst` repeatedly from top to bottom to all hypotheses of the
+ context for which an equality of the form :n:`@ident = t` or :n:`t = @ident`
+ or :n:`@ident := t` exists, with :n:`@ident` not occurring in
+ ``t`` and :n:`@ident` not a section variable with indirect
+ dependencies in the goal.
+
+ .. flag:: Regular Subst Tactic
+
+ This flag controls the behavior of :tacn:`subst`. When it is
+ activated (it is by default), :tacn:`subst` also deals with the following corner cases:
+
+ + A context with ordered hypotheses :n:`@ident`:sub:`1` :n:`= @ident`:sub:`2`
+ and :n:`@ident`:sub:`1` :n:`= t`, or :n:`t′ = @ident`:sub:`1`` with `t′` not
+ a variable, and no other hypotheses of the form :n:`@ident`:sub:`2` :n:`= u`
+ or :n:`u = @ident`:sub:`2`; without the flag, a second call to
+ subst would be necessary to replace :n:`@ident`:sub:`2` by `t` or
+ `t′` respectively.
+ + The presence of a recursive equation which without the flag would
+ be a cause of failure of :tacn:`subst`.
+ + A context with cyclic dependencies as with hypotheses :n:`@ident`:sub:`1` :n:`= f @ident`:sub:`2`
+ and :n:`@ident`:sub:`2` :n:`= g @ident`:sub:`1` which without the
+ flag would be a cause of failure of :tacn:`subst`.
+
+ Additionally, it prevents a local definition such as :n:`@ident := t` to be
+ unfolded which otherwise it would exceptionally unfold in configurations
+ containing hypotheses of the form :n:`@ident = u`, or :n:`u′ = @ident`
+ with `u′` not a variable. Finally, it preserves the initial order of
+ hypotheses, which without the flag it may break.
+ default.
+
+ .. exn:: Cannot find any non-recursive equality over :n:`@ident`.
+ :undocumented:
+
+ .. exn:: Section variable :n:`@ident` occurs implicitly in global declaration :n:`@qualid` present in hypothesis :n:`@ident`.
+ Section variable :n:`@ident` occurs implicitly in global declaration :n:`@qualid` present in the conclusion.
+
+ Raised when the variable is a section variable with indirect
+ dependencies in the goal.
+
+
+.. tacn:: stepl @term
+ :name: stepl
+
+ This tactic is for chaining rewriting steps. It assumes a goal of the
+ form :n:`R @term @term` where ``R`` is a binary relation and relies on a
+ database of lemmas of the form :g:`forall x y z, R x y -> eq x z -> R z y`
+ where `eq` is typically a setoid equality. The application of :n:`stepl @term`
+ then replaces the goal by :n:`R @term @term` and adds a new goal stating
+ :n:`eq @term @term`.
+
+ .. cmd:: Declare Left Step @term
+
+ Adds :n:`@term` to the database used by :tacn:`stepl`.
+
+ This tactic is especially useful for parametric setoids which are not accepted
+ as regular setoids for :tacn:`rewrite` and :tacn:`setoid_replace` (see
+ :ref:`Generalizedrewriting`).
+
+ .. tacv:: stepl @term by @tactic
+
+ This applies :n:`stepl @term` then applies :token:`tactic` to the second goal.
+
+ .. tacv:: stepr @term by @tactic
+ :name: stepr
+
+ This behaves as :tacn:`stepl` but on the right-hand-side of the binary
+ relation. Lemmas are expected to be of the form
+ :g:`forall x y z, R x y -> eq y z -> R x z`.
+
+ .. cmd:: Declare Right Step @term
+
+ Adds :n:`@term` to the database used by :tacn:`stepr`.
+
+
+.. tacn:: change @term
+ :name: change
+
+ This tactic applies to any goal. It implements the rule ``Conv`` given in
+ :ref:`subtyping-rules`. :g:`change U` replaces the current goal `T`
+ with `U` providing that `U` is well-formed and that `T` and `U` are
+ convertible.
+
+ .. exn:: Not convertible.
+ :undocumented:
+
+ .. tacv:: change @term with @term’
+
+ This replaces the occurrences of :n:`@term` by :n:`@term’` in the current goal.
+ The term :n:`@term` and :n:`@term’` must be convertible.
+
+ .. tacv:: change @term at {+ @natural} with @term’
+
+ This replaces the occurrences numbered :n:`{+ @natural}` of :n:`@term` by :n:`@term’`
+ in the current goal. The terms :n:`@term` and :n:`@term’` must be convertible.
+
+ .. exn:: Too few occurrences.
+ :undocumented:
+
+ .. tacv:: change @term {? {? at {+ @natural}} with @term} in @ident
+
+ This applies the :tacn:`change` tactic not to the goal but to the hypothesis :n:`@ident`.
+
+ .. tacv:: now_show @term
+
+ This is a synonym of :n:`change @term`. It can be used to
+ make some proof steps explicit when refactoring a proof script
+ to make it readable.
+
+ .. seealso:: :ref:`Performing computations <performingcomputations>`
+
+.. _performingcomputations:
+
+Performing computations
+---------------------------
+
+.. insertprodn red_expr pattern_occ
+
+.. prodn::
+ red_expr ::= red
+ | hnf
+ | simpl {? @delta_flag } {? @ref_or_pattern_occ }
+ | cbv {? @strategy_flag }
+ | cbn {? @strategy_flag }
+ | lazy {? @strategy_flag }
+ | compute {? @delta_flag }
+ | vm_compute {? @ref_or_pattern_occ }
+ | native_compute {? @ref_or_pattern_occ }
+ | unfold {+, @unfold_occ }
+ | fold {+ @one_term }
+ | pattern {+, @pattern_occ }
+ | @ident
+ delta_flag ::= {? - } [ {+ @reference } ]
+ strategy_flag ::= {+ @red_flag }
+ | @delta_flag
+ red_flag ::= beta
+ | iota
+ | match
+ | fix
+ | cofix
+ | zeta
+ | delta {? @delta_flag }
+ ref_or_pattern_occ ::= @reference {? at @occs_nums }
+ | @one_term {? at @occs_nums }
+ occs_nums ::= {+ {| @natural | @ident } }
+ | - {| @natural | @ident } {* @int_or_var }
+ int_or_var ::= @integer
+ | @ident
+ unfold_occ ::= @reference {? at @occs_nums }
+ pattern_occ ::= @one_term {? at @occs_nums }
+
+This set of tactics implements different specialized usages of the
+tactic :tacn:`change`.
+
+All conversion tactics (including :tacn:`change`) can be parameterized by the
+parts of the goal where the conversion can occur. This is done using
+*goal clauses* which consists in a list of hypotheses and, optionally,
+of a reference to the conclusion of the goal. For defined hypothesis
+it is possible to specify if the conversion should occur on the type
+part, the body part or both (default).
+
+Goal clauses are written after a conversion tactic (tactics :tacn:`set`,
+:tacn:`rewrite`, :tacn:`replace` and :tacn:`autorewrite` also use goal
+clauses) and are introduced by the keyword `in`. If no goal clause is
+provided, the default is to perform the conversion only in the
+conclusion.
+
+The syntax and description of the various goal clauses is the
+following:
+
++ :n:`in {+ @ident} |-` only in hypotheses :n:`{+ @ident}`
++ :n:`in {+ @ident} |- *` in hypotheses :n:`{+ @ident}` and in the
+ conclusion
++ :n:`in * |-` in every hypothesis
++ :n:`in *` (equivalent to in :n:`* |- *`) everywhere
++ :n:`in (type of @ident) (value of @ident) ... |-` in type part of
+ :n:`@ident`, in the value part of :n:`@ident`, etc.
+
+For backward compatibility, the notation :n:`in {+ @ident}` performs
+the conversion in hypotheses :n:`{+ @ident}`.
+
+.. tacn:: cbv {? @strategy_flag }
+ lazy {? @strategy_flag }
+ :name: cbv; lazy
+
+ These parameterized reduction tactics apply to any goal and perform
+ the normalization of the goal according to the specified flags. In
+ correspondence with the kinds of reduction considered in |Coq| namely
+ :math:`\beta` (reduction of functional application), :math:`\delta`
+ (unfolding of transparent constants, see :ref:`vernac-controlling-the-reduction-strategies`),
+ :math:`\iota` (reduction of
+ pattern matching over a constructed term, and unfolding of :g:`fix` and
+ :g:`cofix` expressions) and :math:`\zeta` (contraction of local definitions), the
+ flags are either ``beta``, ``delta``, ``match``, ``fix``, ``cofix``,
+ ``iota`` or ``zeta``. The ``iota`` flag is a shorthand for ``match``, ``fix``
+ and ``cofix``. The ``delta`` flag itself can be refined into
+ :n:`delta [ {+ @qualid} ]` or :n:`delta - [ {+ @qualid} ]`, restricting in the first
+ case the constants to unfold to the constants listed, and restricting in the
+ second case the constant to unfold to all but the ones explicitly mentioned.
+ Notice that the ``delta`` flag does not apply to variables bound by a let-in
+ construction inside the :n:`@term` itself (use here the ``zeta`` flag). In
+ any cases, opaque constants are not unfolded (see :ref:`vernac-controlling-the-reduction-strategies`).
+
+ Normalization according to the flags is done by first evaluating the
+ head of the expression into a *weak-head* normal form, i.e. until the
+ evaluation is blocked by a variable (or an opaque constant, or an
+ axiom), as e.g. in :g:`x u1 ... un` , or :g:`match x with ... end`, or
+ :g:`(fix f x {struct x} := ...) x`, or is a constructed form (a
+ :math:`\lambda`-expression, a constructor, a cofixpoint, an inductive type, a
+ product type, a sort), or is a redex that the flags prevent to reduce. Once a
+ weak-head normal form is obtained, subterms are recursively reduced using the
+ same strategy.
+
+ Reduction to weak-head normal form can be done using two strategies:
+ *lazy* (``lazy`` tactic), or *call-by-value* (``cbv`` tactic). The lazy
+ strategy is a call-by-need strategy, with sharing of reductions: the
+ arguments of a function call are weakly evaluated only when necessary,
+ and if an argument is used several times then it is weakly computed
+ only once. This reduction is efficient for reducing expressions with
+ dead code. For instance, the proofs of a proposition :g:`exists x. P(x)`
+ reduce to a pair of a witness :g:`t`, and a proof that :g:`t` satisfies the
+ predicate :g:`P`. Most of the time, :g:`t` may be computed without computing
+ the proof of :g:`P(t)`, thanks to the lazy strategy.
+
+ The call-by-value strategy is the one used in ML languages: the
+ arguments of a function call are systematically weakly evaluated
+ first. Despite the lazy strategy always performs fewer reductions than
+ the call-by-value strategy, the latter is generally more efficient for
+ evaluating purely computational expressions (i.e. with little dead code).
+
+.. tacv:: compute
+ cbv
+ :name: compute; _
+
+ These are synonyms for ``cbv beta delta iota zeta``.
+
+.. tacv:: lazy
+
+ This is a synonym for ``lazy beta delta iota zeta``.
+
+.. tacv:: compute [ {+ @qualid} ]
+ cbv [ {+ @qualid} ]
+
+ These are synonyms of :n:`cbv beta delta {+ @qualid} iota zeta`.
+
+.. tacv:: compute - [ {+ @qualid} ]
+ cbv - [ {+ @qualid} ]
+
+ These are synonyms of :n:`cbv beta delta -{+ @qualid} iota zeta`.
+
+.. tacv:: lazy [ {+ @qualid} ]
+ lazy - [ {+ @qualid} ]
+
+ These are respectively synonyms of :n:`lazy beta delta {+ @qualid} iota zeta`
+ and :n:`lazy beta delta -{+ @qualid} iota zeta`.
+
+.. tacv:: vm_compute
+ :name: vm_compute
+
+ This tactic evaluates the goal using the optimized call-by-value evaluation
+ bytecode-based virtual machine described in :cite:`CompiledStrongReduction`.
+ This algorithm is dramatically more efficient than the algorithm used for the
+ :tacn:`cbv` tactic, but it cannot be fine-tuned. It is especially interesting for
+ full evaluation of algebraic objects. This includes the case of
+ reflection-based tactics.
+
+.. tacv:: native_compute
+ :name: native_compute
+
+ This tactic evaluates the goal by compilation to |OCaml| as described
+ in :cite:`FullReduction`. If |Coq| is running in native code, it can be
+ typically two to five times faster than :tacn:`vm_compute`. Note however that the
+ compilation cost is higher, so it is worth using only for intensive
+ computations.
+
+ .. flag:: NativeCompute Timing
+
+ This flag causes all calls to the native compiler to print
+ timing information for the conversion to native code,
+ compilation, execution, and reification phases of native
+ compilation. Timing is printed in units of seconds of
+ wall-clock time.
+
+ .. flag:: NativeCompute Profiling
+
+ On Linux, if you have the ``perf`` profiler installed, this flag makes
+ it possible to profile :tacn:`native_compute` evaluations.
+
+ .. opt:: NativeCompute Profile Filename @string
+ :name: NativeCompute Profile Filename
+
+ This option specifies the profile output; the default is
+ ``native_compute_profile.data``. The actual filename used
+ will contain extra characters to avoid overwriting an existing file; that
+ filename is reported to the user.
+ That means you can individually profile multiple uses of
+ :tacn:`native_compute` in a script. From the Linux command line, run ``perf report``
+ on the profile file to see the results. Consult the ``perf`` documentation
+ for more details.
+
+.. flag:: Debug Cbv
+
+ This flag makes :tacn:`cbv` (and its derivative :tacn:`compute`) print
+ information about the constants it encounters and the unfolding decisions it
+ makes.
+
+.. tacn:: red
+ :name: red
+
+ This tactic applies to a goal that has the form::
+
+ forall (x:T1) ... (xk:Tk), T
+
+ with :g:`T` :math:`\beta`:math:`\iota`:math:`\zeta`-reducing to :g:`c t`:sub:`1` :g:`... t`:sub:`n` and :g:`c` a
+ constant. If :g:`c` is transparent then it replaces :g:`c` with its
+ definition (say :g:`t`) and then reduces
+ :g:`(t t`:sub:`1` :g:`... t`:sub:`n` :g:`)` according to :math:`\beta`:math:`\iota`:math:`\zeta`-reduction rules.
+
+.. exn:: Not reducible.
+ :undocumented:
+
+.. exn:: No head constant to reduce.
+ :undocumented:
+
+.. tacn:: hnf
+ :name: hnf
+
+ This tactic applies to any goal. It replaces the current goal with its
+ head normal form according to the :math:`\beta`:math:`\delta`:math:`\iota`:math:`\zeta`-reduction rules, i.e. it
+ reduces the head of the goal until it becomes a product or an
+ irreducible term. All inner :math:`\beta`:math:`\iota`-redexes are also reduced.
+ The behavior of both :tacn:`hnf` can be tuned using the :cmd:`Arguments` command.
+
+ Example: The term :g:`fun n : nat => S n + S n` is not reduced by :n:`hnf`.
+
+.. note::
+ The :math:`\delta` rule only applies to transparent constants (see :ref:`vernac-controlling-the-reduction-strategies`
+ on transparency and opacity).
+
+.. tacn:: cbn
+ simpl
+ :name: cbn; simpl
+
+ These tactics apply to any goal. They try to reduce a term to
+ something still readable instead of fully normalizing it. They perform
+ a sort of strong normalization with two key differences:
+
+ + They unfold a constant if and only if it leads to a :math:`\iota`-reduction,
+ i.e. reducing a match or unfolding a fixpoint.
+ + While reducing a constant unfolding to (co)fixpoints, the tactics
+ use the name of the constant the (co)fixpoint comes from instead of
+ the (co)fixpoint definition in recursive calls.
+
+ The :tacn:`cbn` tactic is claimed to be a more principled, faster and more
+ predictable replacement for :tacn:`simpl`.
+
+ The :tacn:`cbn` tactic accepts the same flags as :tacn:`cbv` and
+ :tacn:`lazy`. The behavior of both :tacn:`simpl` and :tacn:`cbn`
+ can be tuned using the :cmd:`Arguments` command.
+
+ .. todo add "See <subsection about controlling the behavior of reduction strategies>"
+ to TBA section
+
+ Notice that only transparent constants whose name can be reused in the
+ recursive calls are possibly unfolded by :tacn:`simpl`. For instance a
+ constant defined by :g:`plus' := plus` is possibly unfolded and reused in
+ the recursive calls, but a constant such as :g:`succ := plus (S O)` is
+ never unfolded. This is the main difference between :tacn:`simpl` and :tacn:`cbn`.
+ The tactic :tacn:`cbn` reduces whenever it will be able to reuse it or not:
+ :g:`succ t` is reduced to :g:`S t`.
+
+.. tacv:: cbn [ {+ @qualid} ]
+ cbn - [ {+ @qualid} ]
+
+ These are respectively synonyms of :n:`cbn beta delta [ {+ @qualid} ] iota zeta`
+ and :n:`cbn beta delta - [ {+ @qualid} ] iota zeta` (see :tacn:`cbn`).
+
+.. tacv:: simpl @pattern
+
+ This applies :tacn:`simpl` only to the subterms matching
+ :n:`@pattern` in the current goal.
+
+.. tacv:: simpl @pattern at {+ @natural}
+
+ This applies :tacn:`simpl` only to the :n:`{+ @natural}` occurrences of the subterms
+ matching :n:`@pattern` in the current goal.
+
+ .. exn:: Too few occurrences.
+ :undocumented:
+
+.. tacv:: simpl @qualid
+ simpl @string
+
+ This applies :tacn:`simpl` only to the applicative subterms whose head occurrence
+ is the unfoldable constant :n:`@qualid` (the constant can be referred to by
+ its notation using :n:`@string` if such a notation exists).
+
+.. tacv:: simpl @qualid at {+ @natural}
+ simpl @string at {+ @natural}
+
+ This applies :tacn:`simpl` only to the :n:`{+ @natural}` applicative subterms whose
+ head occurrence is :n:`@qualid` (or :n:`@string`).
+
+.. flag:: Debug RAKAM
+
+ This flag makes :tacn:`cbn` print various debugging information.
+ ``RAKAM`` is the Refolding Algebraic Krivine Abstract Machine.
+
+.. tacn:: unfold @qualid
+ :name: unfold
+
+ This tactic applies to any goal. The argument qualid must denote a
+ defined transparent constant or local definition (see
+ :ref:`gallina-definitions` and
+ :ref:`vernac-controlling-the-reduction-strategies`). The tactic
+ :tacn:`unfold` applies the :math:`\delta` rule to each occurrence
+ of the constant to which :n:`@qualid` refers in the current goal
+ and then replaces it with its :math:`\beta\iota\zeta`-normal form.
+ Use the general reduction tactics if you want to avoid this final
+ reduction, for instance :n:`cbv delta [@qualid]`.
+
+ .. exn:: Cannot coerce @qualid to an evaluable reference.
+
+ This error is frequent when trying to unfold something that has
+ defined as an inductive type (or constructor) and not as a
+ definition.
+
+ .. example::
+
+ .. coqtop:: abort all fail
+
+ Goal 0 <= 1.
+ unfold le.
+
+ This error can also be raised if you are trying to unfold
+ something that has been marked as opaque.
+
+ .. example::
+
+ .. coqtop:: abort all fail
+
+ Opaque Nat.add.
+ Goal 1 + 0 = 1.
+ unfold Nat.add.
+
+ .. tacv:: unfold @qualid in @goal_occurrences
+
+ Replaces :n:`@qualid` in hypothesis (or hypotheses) designated
+ by :token:`goal_occurrences` with its definition and replaces
+ the hypothesis with its :math:`\beta`:math:`\iota` normal form.
+
+ .. tacv:: unfold {+, @qualid}
+
+ Replaces :n:`{+, @qualid}` with their definitions and replaces
+ the current goal with its :math:`\beta`:math:`\iota` normal
+ form.
+
+ .. tacv:: unfold {+, @qualid at @occurrences }
+
+ The list :token:`occurrences` specify the occurrences of
+ :n:`@qualid` to be unfolded. Occurrences are located from left
+ to right.
+
+ .. exn:: Bad occurrence number of @qualid.
+ :undocumented:
+
+ .. exn:: @qualid does not occur.
+ :undocumented:
+
+ .. tacv:: unfold @string
+
+ If :n:`@string` denotes the discriminating symbol of a notation
+ (e.g. "+") or an expression defining a notation (e.g. `"_ +
+ _"`), and this notation denotes an application whose head symbol
+ is an unfoldable constant, then the tactic unfolds it.
+
+ .. tacv:: unfold @string%@ident
+
+ This is variant of :n:`unfold @string` where :n:`@string` gets
+ its interpretation from the scope bound to the delimiting key
+ :token:`ident` instead of its default interpretation (see
+ :ref:`Localinterpretationrulesfornotations`).
+
+ .. tacv:: unfold {+, {| @qualid | @string{? %@ident } } {? at @occurrences } } {? in @goal_occurrences }
+
+ This is the most general form.
+
+.. tacn:: fold @term
+ :name: fold
+
+ This tactic applies to any goal. The term :n:`@term` is reduced using the
+ :tacn:`red` tactic. Every occurrence of the resulting :n:`@term` in the goal is
+ then replaced by :n:`@term`. This tactic is particularly useful when a fixpoint
+ definition has been wrongfully unfolded, making the goal very hard to read.
+ On the other hand, when an unfolded function applied to its argument has been
+ reduced, the :tacn:`fold` tactic won't do anything.
+
+ .. example::
+
+ .. coqtop:: all abort
+
+ Goal ~0=0.
+ unfold not.
+ Fail progress fold not.
+ pattern (0 = 0).
+ fold not.
+
+ .. tacv:: fold {+ @term}
+
+ Equivalent to :n:`fold @term ; ... ; fold @term`.
+
+.. tacn:: pattern @term
+ :name: pattern
+
+ This command applies to any goal. The argument :n:`@term` must be a free
+ subterm of the current goal. The command pattern performs :math:`\beta`-expansion
+ (the inverse of :math:`\beta`-reduction) of the current goal (say :g:`T`) by
+
+ + replacing all occurrences of :n:`@term` in :g:`T` with a fresh variable
+ + abstracting this variable
+ + applying the abstracted goal to :n:`@term`
+
+ For instance, if the current goal :g:`T` is expressible as
+ :math:`\varphi`:g:`(t)` where the notation captures all the instances of :g:`t`
+ in :math:`\varphi`:g:`(t)`, then :n:`pattern t` transforms it into
+ :g:`(fun x:A =>` :math:`\varphi`:g:`(x)) t`. This tactic can be used, for
+ instance, when the tactic ``apply`` fails on matching.
+
+.. tacv:: pattern @term at {+ @natural}
+
+ Only the occurrences :n:`{+ @natural}` of :n:`@term` are considered for
+ :math:`\beta`-expansion. Occurrences are located from left to right.
+
+.. tacv:: pattern @term at - {+ @natural}
+
+ All occurrences except the occurrences of indexes :n:`{+ @natural }`
+ of :n:`@term` are considered for :math:`\beta`-expansion. Occurrences are located from
+ left to right.
+
+.. tacv:: pattern {+, @term}
+
+ Starting from a goal :math:`\varphi`:g:`(t`:sub:`1` :g:`... t`:sub:`m`:g:`)`,
+ the tactic :n:`pattern t`:sub:`1`:n:`, ..., t`:sub:`m` generates the
+ equivalent goal
+ :g:`(fun (x`:sub:`1`:g:`:A`:sub:`1`:g:`) ... (x`:sub:`m` :g:`:A`:sub:`m` :g:`) =>`:math:`\varphi`:g:`(x`:sub:`1` :g:`... x`:sub:`m` :g:`)) t`:sub:`1` :g:`... t`:sub:`m`.
+ If :g:`t`:sub:`i` occurs in one of the generated types :g:`A`:sub:`j` these
+ occurrences will also be considered and possibly abstracted.
+
+.. tacv:: pattern {+, @term at {+ @natural}}
+
+ This behaves as above but processing only the occurrences :n:`{+ @natural}` of
+ :n:`@term` starting from :n:`@term`.
+
+.. tacv:: pattern {+, @term {? at {? -} {+, @natural}}}
+
+ This is the most general syntax that combines the different variants.
+
+.. tacn:: with_strategy @strategy_level_or_var [ {+ @reference } ] @ltac_expr3
+ :name: with_strategy
+
+ Executes :token:`ltac_expr3`, applying the alternate unfolding
+ behavior that the :cmd:`Strategy` command controls, but only for
+ :token:`ltac_expr3`. This can be useful for guarding calls to
+ reduction in tactic automation to ensure that certain constants are
+ never unfolded by tactics like :tacn:`simpl` and :tacn:`cbn` or to
+ ensure that unfolding does not fail.
+
+ .. example::
+
+ .. coqtop:: all reset abort
+
+ Opaque id.
+ Goal id 10 = 10.
+ Fail unfold id.
+ with_strategy transparent [id] unfold id.
+
+ .. warning::
+
+ Use this tactic with care, as effects do not persist past the
+ end of the proof script. Notably, this fine-tuning of the
+ conversion strategy is not in effect during :cmd:`Qed` nor
+ :cmd:`Defined`, so this tactic is most useful either in
+ combination with :tacn:`abstract`, which will check the proof
+ early while the fine-tuning is still in effect, or to guard
+ calls to conversion in tactic automation to ensure that, e.g.,
+ :tacn:`unfold` does not fail just because the user made a
+ constant :cmd:`Opaque`.
+
+ This can be illustrated with the following example involving the
+ factorial function.
+
+ .. coqtop:: in reset
+
+ Fixpoint fact (n : nat) : nat :=
+ match n with
+ | 0 => 1
+ | S n' => n * fact n'
+ end.
+
+ Suppose now that, for whatever reason, we want in general to
+ unfold the :g:`id` function very late during conversion:
+
+ .. coqtop:: in
+
+ Strategy 1000 [id].
+
+ If we try to prove :g:`id (fact n) = fact n` by
+ :tacn:`reflexivity`, it will now take time proportional to
+ :math:`n!`, because |Coq| will keep unfolding :g:`fact` and
+ :g:`*` and :g:`+` before it unfolds :g:`id`, resulting in a full
+ computation of :g:`fact n` (in unary, because we are using
+ :g:`nat`), which takes time :math:`n!`. We can see this cross
+ the relevant threshold at around :math:`n = 9`:
+
+ .. coqtop:: all abort
+
+ Goal True.
+ Time assert (id (fact 8) = fact 8) by reflexivity.
+ Time assert (id (fact 9) = fact 9) by reflexivity.
+
+ Note that behavior will be the same if you mark :g:`id` as
+ :g:`Opaque` because while most reduction tactics refuse to
+ unfold :g:`Opaque` constants, conversion treats :g:`Opaque` as
+ merely a hint to unfold this constant last.
+
+ We can get around this issue by using :tacn:`with_strategy`:
+
+ .. coqtop:: all
+
+ Goal True.
+ Fail Timeout 1 assert (id (fact 100) = fact 100) by reflexivity.
+ Time assert (id (fact 100) = fact 100) by with_strategy -1 [id] reflexivity.
+
+ However, when we go to close the proof, we will run into
+ trouble, because the reduction strategy changes are local to the
+ tactic passed to :tacn:`with_strategy`.
+
+ .. coqtop:: all abort fail
+
+ exact I.
+ Timeout 1 Defined.
+
+ We can fix this issue by using :tacn:`abstract`:
+
+ .. coqtop:: all
+
+ Goal True.
+ Time assert (id (fact 100) = fact 100) by with_strategy -1 [id] abstract reflexivity.
+ exact I.
+ Time Defined.
+
+ On small examples this sort of behavior doesn't matter, but
+ because |Coq| is a super-linear performance domain in so many
+ places, unless great care is taken, tactic automation using
+ :tacn:`with_strategy` may not be robustly performant when
+ scaling the size of the input.
+
+ .. warning::
+
+ In much the same way this tactic does not play well with
+ :cmd:`Qed` and :cmd:`Defined` without using :tacn:`abstract` as
+ an intermediary, this tactic does not play well with ``coqchk``,
+ even when used with :tacn:`abstract`, due to the inability of
+ tactics to persist information about conversion hints in the
+ proof term. See `#12200
+ <https://github.com/coq/coq/issues/12200>`_ for more details.
+
+Conversion tactics applied to hypotheses
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. tacn:: @tactic in {+, @ident}
+
+ Applies :token:`tactic` (any of the conversion tactics listed in this
+ section) to the hypotheses :n:`{+ @ident}`.
+
+ If :token:`ident` is a local definition, then :token:`ident` can be replaced by
+ :n:`type of @ident` to address not the body but the type of the local
+ definition.
+
+ Example: :n:`unfold not in (type of H1) (type of H3)`.
diff --git a/doc/sphinx/user-extensions/proof-schemes.rst b/doc/sphinx/user-extensions/proof-schemes.rst
index 8e23e61018..abecee8459 100644
--- a/doc/sphinx/user-extensions/proof-schemes.rst
+++ b/doc/sphinx/user-extensions/proof-schemes.rst
@@ -8,35 +8,36 @@ Proof schemes
Generation of induction principles with ``Scheme``
--------------------------------------------------------
-The ``Scheme`` command is a high-level tool for generating automatically
-(possibly mutual) induction principles for given types and sorts. Its
-syntax follows the schema:
+.. cmd:: Scheme {? @ident := } @scheme_kind {* with {? @ident := } @scheme_kind }
-.. cmd:: Scheme @ident__1 := Induction for @ident__2 Sort @sort {* with @ident__i := Induction for @ident__j Sort @sort}
+ .. insertprodn scheme_kind sort_family
- This command is a high-level tool for generating automatically
+ .. prodn::
+ scheme_kind ::= Equality for @reference
+ | {| Induction | Minimality | Elimination | Case } for @reference Sort @sort_family
+ sort_family ::= Set
+ | Prop
+ | SProp
+ | Type
+
+ A high-level tool for automatically generating
(possibly mutual) induction principles for given types and sorts.
- Each :n:`@ident__j` is a different inductive type identifier belonging to
+ Each :n:`@reference` is a different inductive type identifier belonging to
the same package of mutual inductive definitions.
- The command generates the :n:`@ident__i`\s to be mutually recursive
- definitions. Each term :n:`@ident__i` proves a general principle of mutual
- induction for objects in type :n:`@ident__j`.
-
-.. cmdv:: Scheme @ident := Minimality for @ident Sort @sort {* with @ident := Minimality for @ident' Sort @sort}
-
- Same as before but defines a non-dependent elimination principle more
- natural in case of inductively defined relations.
+ The command generates the :n:`@ident`\s as mutually recursive
+ definitions. Each term :n:`@ident` proves a general principle of mutual
+ induction for objects in type :n:`@reference`.
-.. cmdv:: Scheme Equality for @ident
- :name: Scheme Equality
+ :n:`@ident`
+ The name of the scheme. If not provided, the scheme name will be determined automatically
+ from the sorts involved.
- Tries to generate a Boolean equality and a proof of the decidability of the usual equality. If `ident`
- involves some other inductive types, their equality has to be defined first.
+ :n:`Minimality for @reference Sort @sort_family`
+ Defines a non-dependent elimination principle more natural for inductively defined relations.
-.. cmdv:: Scheme Induction for @ident Sort @sort {* with Induction for @ident Sort @sort}
-
- If you do not provide the name of the schemes, they will be automatically computed from the
- sorts involved (works also with Minimality).
+ :n:`Equality for @reference`
+ Tries to generate a Boolean equality and a proof of the decidability of the usual equality.
+ If :token:`reference` involves other inductive types, their equality has to be defined first.
.. example::
@@ -128,7 +129,7 @@ Automatic declaration of schemes
.. warning::
- You have to be careful with these flags since Coq may now reject well-defined
+ You have to be careful with these flags since |Coq| may now reject well-defined
inductive types because it cannot compute a Boolean equality for them.
.. flag:: Rewriting Schemes
@@ -138,13 +139,13 @@ Automatic declaration of schemes
Combined Scheme
~~~~~~~~~~~~~~~~~~~~~~
-.. cmd:: Combined Scheme @ident from {+, @ident__i}
+.. cmd:: Combined Scheme @ident__def from {+, @ident }
This command is a tool for combining induction principles generated
by the :cmd:`Scheme` command.
- Each :n:`@ident__i` is a different inductive principle that must belong
+ Each :n:`@ident` is a different inductive principle that must belong
to the same package of mutual inductive principle definitions.
- This command generates :n:`@ident` to be the conjunction of the
+ This command generates :n:`@ident__def` as the conjunction of the
principles: it is built from the common premises of the principles
and concluded by the conjunction of their conclusions.
In the case where all the inductive principles used are in sort
@@ -197,32 +198,30 @@ Combined Scheme
Generation of inversion principles with ``Derive`` ``Inversion``
-----------------------------------------------------------------
-.. cmd:: Derive Inversion @ident with @ident Sort @sort
- Derive Inversion @ident with (forall {* @binder }, @ident @term) Sort @sort
+.. cmd:: Derive Inversion @ident with @one_term {? Sort @sort_family }
- This command generates an inversion principle for the
- :tacn:`inversion ... using ...` tactic. The first :token:`ident` is the name
- of the generated principle. The second :token:`ident` should be an inductive
- predicate, and :n:`{* @binder }` the variables occurring in the term
- :token:`term`. This command generates the inversion lemma for the sort
- :token:`sort` corresponding to the instance :n:`forall {* @binder }, @ident @term`.
- When applied, it is equivalent to having inverted the instance with the
- tactic :g:`inversion`.
+ Generates an inversion lemma for the
+ :tacn:`inversion ... using ...` tactic. :token:`ident` is the name
+ of the generated lemma. :token:`one_term` should be in the form
+ :token:`qualid` or :n:`(forall {+ @binder }, @qualid @term)` where
+ :token:`qualid` is the name of an inductive
+ predicate and :n:`{+ @binder }` binds the variables occurring in the term
+ :token:`term`. The lemma is generated for the sort
+ :token:`sort_family` corresponding to :token:`one_term`.
+ Applying the lemma is equivalent to inverting the instance with the
+ :tacn:`inversion` tactic.
-.. cmdv:: Derive Inversion_clear @ident with @ident Sort @sort
- Derive Inversion_clear @ident with (forall {* @binder }, @ident @term) Sort @sort
+.. cmd:: Derive Inversion_clear @ident with @one_term {? Sort @sort_family }
When applied, it is equivalent to having inverted the instance with the
tactic inversion replaced by the tactic `inversion_clear`.
-.. cmdv:: Derive Dependent Inversion @ident with @ident Sort @sort
- Derive Dependent Inversion @ident with (forall {* @binder }, @ident @term) Sort @sort
+.. cmd:: Derive Dependent Inversion @ident with @one_term Sort @sort_family
When applied, it is equivalent to having inverted the instance with
the tactic `dependent inversion`.
-.. cmdv:: Derive Dependent Inversion_clear @ident with @ident Sort @sort
- Derive Dependent Inversion_clear @ident with (forall {* @binder }, @ident @term) Sort @sort
+.. cmd:: Derive Dependent Inversion_clear @ident with @one_term Sort @sort_family
When applied, it is equivalent to having inverted the instance
with the tactic `dependent inversion_clear`.
diff --git a/doc/sphinx/user-extensions/syntax-extensions.rst b/doc/sphinx/user-extensions/syntax-extensions.rst
index 5148fa84c9..9d1fcc160d 100644
--- a/doc/sphinx/user-extensions/syntax-extensions.rst
+++ b/doc/sphinx/user-extensions/syntax-extensions.rst
@@ -3,7 +3,7 @@
Syntax extensions and notation scopes
=====================================
-In this chapter, we introduce advanced commands to modify the way Coq
+In this chapter, we introduce advanced commands to modify the way |Coq|
parses and prints objects, i.e. the translations between the concrete
and internal representations of terms and commands.
@@ -57,22 +57,21 @@ to represent :g:`(and A B)`:
Notations must be in double quotes, except when the
abbreviation has the form of an ordinary applicative expression;
see :ref:`Abbreviations`. The notation consists of *tokens* separated by
-spaces. Alphanumeric strings (such as ``A`` and ``B``) are the *parameters*
+spaces. Tokens which are identifiers (such as ``A``, ``x0'``, etc.) are the *parameters*
of the notation. Each of them must occur at least once in the abbreviated term. The
other elements of the string (such as ``/\``) are the *symbols*.
-Substrings enclosed in single quotes are treated as literals. This is necessary
-for substrings that would otherwise be interpreted as :n:`@ident`\s. 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.
+Identifiers enclosed in single quotes are treated as symbols and thus
+lose their role of parameters. In the same vein, every symbol of at
+least 3 characters and starting with a simple quote must be quoted
+(then it starts with two single quotes). Here is an example.
.. coqtop:: in
Notation "'IF' c1 'then' c2 'else' c3" := (IF_then_else c1 c2 c3).
A notation binds a syntactic expression to a term. Unless the parser
-and pretty-printer of Coq already know how to deal with the syntactic
+and pretty-printer of |Coq| already know how to deal with the syntactic
expression (such as through :cmd:`Reserved Notation` or for notations
that contain only literals), explicit precedences and
associativity rules have to be given.
@@ -82,13 +81,14 @@ associativity rules have to be given.
The right-hand side of a notation is interpreted at the time the notation is
given. In particular, disambiguation of constants, :ref:`implicit arguments
<ImplicitArguments>` and other notations are resolved at the
- time of the declaration of the notation.
+ time of the declaration of the notation. The right-hand side is
+ currently typed only at use time but this may change in the future.
Precedences and associativity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mixing different symbolic notations in the same text may cause serious
-parsing ambiguity. To deal with the ambiguity of notations, Coq uses
+parsing ambiguity. To deal with the ambiguity of notations, |Coq| uses
precedence levels ranging from 0 to 100 (plus one extra level numbered
200) and associativity rules.
@@ -99,7 +99,7 @@ Consider for example the new notation
Notation "A \/ B" := (or A B).
Clearly, an expression such as :g:`forall A:Prop, True /\ A \/ A \/ False`
-is ambiguous. To tell the Coq parser how to interpret the
+is ambiguous. To tell the |Coq| parser how to interpret the
expression, a priority between the symbols ``/\`` and ``\/`` has to be
given. Assume for instance that we want conjunction to bind more than
disjunction. This is expressed by assigning a precedence level to each
@@ -117,7 +117,7 @@ defaults to :g:`True /\ (False /\ False)` (right associativity) or to
expression is not well-formed and that parentheses are mandatory (this is a “no
associativity”) [#no_associativity]_. We do not know of a special convention for
the associativity of disjunction and conjunction, so let us apply
-right associativity (which is the choice of Coq).
+right associativity (which is the choice of |Coq|).
Precedence levels and associativity rules of notations are specified with a list of
parenthesized :n:`@syntax_modifier`\s. Here is how the previous examples refine:
@@ -187,7 +187,7 @@ left. See the next section for more about factorization.
Simple factorization rules
~~~~~~~~~~~~~~~~~~~~~~~~~~
-Coq extensible parsing is performed by *Camlp5* which is essentially a LL1
+|Coq| extensible parsing is performed by *Camlp5* which is essentially a LL1
parser: it decides which notation to parse by looking at tokens from left to right.
Hence, some care has to be taken not to hide already existing rules by new
rules. Some simple left factorization work has to be done. Here is an example.
@@ -209,16 +209,16 @@ need to force the parsing level of ``y``, as follows.
Notation "x < y" := (lt x y) (at level 70).
Notation "x < y < z" := (x < y /\ y < z) (at level 70, y at next level).
-For the sake of factorization with Coq predefined rules, simple rules
+For the sake of factorization with |Coq| predefined rules, simple rules
have to be observed for notations starting with a symbol, e.g., rules
starting with “\ ``{``\ ” or “\ ``(``\ ” should be put at level 0. The list
-of Coq predefined notations can be found in the chapter on :ref:`thecoqlibrary`.
+of |Coq| predefined notations can be found in the chapter on :ref:`thecoqlibrary`.
Displaying symbolic notations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The command :cmd:`Notation` has an effect both on the Coq parser and on the
-Coq printer. For example:
+The command :cmd:`Notation` has an effect both on the |Coq| parser and on the
+|Coq| printer. For example:
.. coqtop:: all
@@ -226,7 +226,7 @@ Coq printer. For example:
However, printing, especially pretty-printing, also requires some
care. We may want specific indentations, line breaks, alignment if on
-several lines, etc. For pretty-printing, |Coq| relies on |ocaml|
+several lines, etc. For pretty-printing, |Coq| relies on |OCaml|
formatting library, which provides indentation and automatic line
breaks depending on page width by means of *formatting boxes*.
@@ -299,12 +299,29 @@ 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.
-.. note:: Sometimes, a notation is expected only for the parser. To do
- so, the option ``only parsing`` is allowed in the list of :n:`@syntax_modifier`\s
- in :cmd:`Notation`. Conversely, the ``only printing`` :n:`@syntax_modifier` can be
- used to declare that a notation should only be used for printing and
- should not declare a parsing rule. In particular, such notations do
- not modify the parser.
+.. note::
+
+ The default for a notation is to be used both for parsing and
+ printing. It is possible to declare a notation only for parsing by
+ adding the option ``only parsing`` to the list of
+ :n:`@syntax_modifier`\s of :cmd:`Notation`. Symmetrically, the
+ ``only printing`` :n:`@syntax_modifier` can be used to declare that
+ a notation should only be used for printing.
+
+ If a notation to be used both for parsing and printing is
+ overriden, both the parsing and printing are invalided, even if the
+ overriding rule is only parsing.
+
+ If a given notation string occurs only in ``only printing`` rules,
+ the parser is not modified at all.
+
+ To a given notation string and scope can be attached at most one
+ notation with both parsing and printing or with only
+ parsing. Contrastingly, an arbitrary number of ``only printing``
+ notations differing in their right-hand sides but only a unique
+ right-hand side can be attached to a given string and
+ scope. Obviously, expressions printed by means of such extra
+ printing rules will not be reparsed to the same form.
The Infix command
~~~~~~~~~~~~~~~~~~
@@ -332,12 +349,12 @@ Reserving notations
.. cmd:: Reserved Notation @string {? ( {+, @syntax_modifier } ) }
- A given notation may be used in different contexts. Coq expects all
+ A given notation may be used in different contexts. |Coq| expects all
uses of the notation to be defined at the same precedence and with the
same associativity. To avoid giving the precedence and associativity
every time, this command declares a parsing rule (:token:`string`) in advance
without giving its interpretation. Here is an example from the initial
- state of Coq.
+ state of |Coq|.
.. coqtop:: in
@@ -368,8 +385,8 @@ a :token:`decl_notations` clause after the definition of the (co)inductive type
(co)recursive term (or after the definition of each of them in case of mutual
definitions). The exact syntax is given by :n:`@decl_notation` for inductive,
co-inductive, recursive and corecursive definitions and in :ref:`record-types`
-for records. Note that only syntax modifiers that do not require to add or
-change a parsing rule are accepted.
+for records. Note that only syntax modifiers that do not require adding or
+changing a parsing rule are accepted.
.. insertprodn decl_notations decl_notation
@@ -427,7 +444,7 @@ Displaying information about notations
This command doesn't display all nonterminals of the grammar. For example,
productions shown by `Print Grammar tactic` refer to nonterminals `tactic_then_locality`
- and `tactic_then_gen` which are not shown and can't be printed.
+ and `for_each_goal` which are not shown and can't be printed.
Most of the grammar in the documentation was updated in 8.12 to make it accurate and
readable. This was done using a new developer tool that extracts the grammar from the
@@ -460,16 +477,16 @@ Displaying information about notations
such as `1+2*3` in the usual way as `1+(2*3)`. However, most nonterminals have a single level.
For example, this output from `Print Grammar tactic` shows the first 3 levels for
- `tactic_expr`, designated as "5", "4" and "3". Level 3 is right-associative,
+ `ltac_expr`, designated as "5", "4" and "3". Level 3 is right-associative,
which applies to the productions within it, such as the `try` construct::
- Entry tactic_expr is
+ Entry ltac_expr is
[ "5" RIGHTA
[ binder_tactic ]
| "4" LEFTA
[ SELF; ";"; binder_tactic
| SELF; ";"; SELF
- | SELF; ";"; tactic_then_locality; tactic_then_gen; "]" ]
+ | SELF; ";"; tactic_then_locality; for_each_goal; "]" ]
| "3" RIGHTA
[ IDENT "try"; SELF
:
@@ -493,7 +510,7 @@ Displaying information about notations
The output for `Print Grammar constr` includes :cmd:`Notation` definitions,
which are dynamically added to the grammar at run time.
- For example, in the definition for `operconstr`, the production on the second line shown
+ For example, in the definition for `term`, the production on the second line shown
here is defined by a :cmd:`Reserved Notation` command in `Notations.v`::
| "50" LEFTA
@@ -745,7 +762,7 @@ recursive patterns. The basic example is:
Notation "[ x ; .. ; y ]" := (cons x .. (cons y nil) ..).
On the right-hand side, an extra construction of the form ``.. t ..`` can
-be used. Notice that ``..`` is part of the Coq syntax and it must not be
+be used. Notice that ``..`` is part of the |Coq| syntax and it must not be
confused with the three-dots notation “``…``” used in this manual to denote
a sequence of arbitrary size.
@@ -925,7 +942,7 @@ Custom entries
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
+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 @natural`, where :n:`@natural` refers to the level.
@@ -979,7 +996,7 @@ associated to the custom entry ``expr``. The level can be omitted, as in
Notation "[ e ]" := e (e custom expr).
-in which case Coq infer it. If the sub-expression is at a border of
+in which case |Coq| infer it. If the sub-expression is at a border of
the notation (as e.g. ``x`` and ``y`` in ``x + y``), the level is
determined by the associativity. If the sub-expression is not at the
border of the notation (as e.g. ``e`` in ``"[ e ]``), the level is
@@ -1080,7 +1097,7 @@ Here are the syntax elements used by the various notation commands.
time. Type checking is done only at the time of use of the notation.
.. note:: Some examples of Notation may be found in the files composing
- the initial state of Coq (see directory :file:`$COQLIB/theories/Init`).
+ the initial state of |Coq| (see directory :file:`$COQLIB/theories/Init`).
.. note:: The notation ``"{ x }"`` has a special status in the main grammars of
terms and patterns so that
@@ -1105,7 +1122,7 @@ Here are the syntax elements used by the various notation commands.
.. warn:: Use of @string Notation is deprecated as it is inconsistent with pattern syntax.
This warning is disabled by default to avoid spurious diagnostics
- due to legacy notation in the Coq standard library.
+ due to legacy notation in the |Coq| standard library.
It can be turned on with the ``-w disj-pattern-notation`` flag.
.. _Scopes:
@@ -1139,7 +1156,7 @@ Most commands use :token:`scope_name`; :token:`scope_key`\s are used within :tok
.. cmd:: Declare Scope @scope_name
Declares a new notation scope. Note that the initial
- state of Coq declares the following notation scopes:
+ state of |Coq| declares the following notation scopes:
``core_scope``, ``type_scope``, ``function_scope``, ``nat_scope``,
``bool_scope``, ``list_scope``, ``int_scope``, ``uint_scope``.
@@ -1291,10 +1308,10 @@ recognized to be a ``Funclass`` instance, i.e., of type :g:`forall x:A, B` or
.. _notation-scopes:
-Notation scopes used in the standard library of Coq
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Notation scopes used in the standard library of |Coq|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-We give an overview of the scopes used in the standard library of Coq.
+We give an overview of the scopes used in the standard library of |Coq|.
For a complete list of notations in each scope, use the commands :cmd:`Print
Scopes` or :cmd:`Print Scope`.
@@ -1360,7 +1377,7 @@ Scopes` or :cmd:`Print Scope`.
``string_scope``
This scope includes notation for strings as elements of the type string.
- Special characters and escaping follow Coq conventions on strings (see
+ Special characters and escaping follow |Coq| conventions on strings (see
:ref:`lexical-conventions`). Especially, there is no convention to visualize non
printable characters of a string. The file :file:`String.v` shows an example
that contains quotes, a newline and a beep (i.e. the ASCII character
@@ -1369,7 +1386,7 @@ Scopes` or :cmd:`Print Scope`.
``char_scope``
This scope includes interpretation for all strings of the form ``"c"``
where :g:`c` is an ASCII character, or of the form ``"nnn"`` where nnn is
- a three-digits number (possibly with leading 0's), or of the form
+ a three-digit number (possibly with leading 0s), or of the form
``""""``. Their respective denotations are the ASCII code of :g:`c`, the
decimal ASCII code ``nnn``, or the ascii code of the character ``"`` (i.e.
the ASCII code 34), all of them being represented in the type :g:`ascii`.
@@ -1461,7 +1478,7 @@ Abbreviations
An abbreviation expects no precedence nor associativity, since it
is parsed as an usual application. Abbreviations are used as
- much as possible by the Coq printers unless the modifier ``(only
+ much as possible by the |Coq| printers unless the modifier ``(only
parsing)`` is given.
An abbreviation is bound to an absolute name as an ordinary definition is
@@ -1536,16 +1553,18 @@ numbers (see :ref:`datatypes`).
Number notations
~~~~~~~~~~~~~~~~
-.. cmd:: Number Notation @qualid__type @qualid__parse @qualid__print : @scope_name {? @numeral_modifier }
+.. cmd:: Number Notation @qualid__type @qualid__parse @qualid__print {? ( {+, @number_modifier } ) } : @scope_name
:name: Number Notation
- .. insertprodn numeral_modifier numeral_modifier
+ .. insertprodn number_modifier number_string_via
.. prodn::
- numeral_modifier ::= ( warning after @bignat )
- | ( abstract after @bignat )
+ number_modifier ::= warning after @bignat
+ | abstract after @bignat
+ | @number_string_via
+ number_string_via ::= via @qualid mapping [ {+, {| @qualid => @qualid | [ @qualid ] => @qualid } } ]
- This command allows the user to customize the way numeral literals
+ This command allows the user to customize the way number literals
are parsed and printed.
:n:`@qualid__type`
@@ -1554,32 +1573,32 @@ Number notations
parsing and printing functions, respectively. The parsing function
:n:`@qualid__parse` should have one of the following types:
- * :n:`Numeral.int -> @qualid__type`
- * :n:`Numeral.int -> option @qualid__type`
- * :n:`Numeral.uint -> @qualid__type`
- * :n:`Numeral.uint -> option @qualid__type`
+ * :n:`Number.int -> @qualid__type`
+ * :n:`Number.int -> option @qualid__type`
+ * :n:`Number.uint -> @qualid__type`
+ * :n:`Number.uint -> option @qualid__type`
* :n:`Z -> @qualid__type`
* :n:`Z -> option @qualid__type`
- * :n:`Numeral.numeral -> @qualid__type`
- * :n:`Numeral.numeral -> option @qualid__type`
+ * :n:`Number.number -> @qualid__type`
+ * :n:`Number.number -> option @qualid__type`
And the printing function :n:`@qualid__print` should have one of the
following types:
- * :n:`@qualid__type -> Numeral.int`
- * :n:`@qualid__type -> option Numeral.int`
- * :n:`@qualid__type -> Numeral.uint`
- * :n:`@qualid__type -> option Numeral.uint`
+ * :n:`@qualid__type -> Number.int`
+ * :n:`@qualid__type -> option Number.int`
+ * :n:`@qualid__type -> Number.uint`
+ * :n:`@qualid__type -> option Number.uint`
* :n:`@qualid__type -> Z`
* :n:`@qualid__type -> option Z`
- * :n:`@qualid__type -> Numeral.numeral`
- * :n:`@qualid__type -> option Numeral.numeral`
+ * :n:`@qualid__type -> Number.number`
+ * :n:`@qualid__type -> option Number.number`
.. deprecated:: 8.12
- Numeral notations on :g:`Decimal.uint`, :g:`Decimal.int` and
- :g:`Decimal.decimal` are replaced respectively by numeral
- notations on :g:`Numeral.uint`, :g:`Numeral.int` and
- :g:`Numeral.numeral`.
+ Number notations on :g:`Decimal.uint`, :g:`Decimal.int` and
+ :g:`Decimal.decimal` are replaced respectively by number
+ notations on :g:`Number.uint`, :g:`Number.int` and
+ :g:`Number.number`.
When parsing, the application of the parsing function
:n:`@qualid__parse` to the number will be fully reduced, and universes
@@ -1589,7 +1608,44 @@ Number notations
function application, constructors, inductive type families,
sorts, and primitive integers) will be considered for printing.
- :n:`( warning after @bignat )`
+ .. _number-string-via:
+
+ :n:`via @qualid__ind mapping [ {+, @qualid__constant => @qualid__constructor } ]`
+ When using this option, :n:`@qualid__type` no
+ longer needs to be an inductive type and is instead mapped to the
+ inductive type :n:`@qualid__ind` according to the provided
+ list of pairs, whose first component :n:`@qualid__constant` is a
+ constant of type :n:`@qualid__type`
+ (or a function of type :n:`{* _ -> } @qualid__type`) and the second a
+ constructor of type :n:`@qualid__ind`. The type
+ :n:`@qualid__type` is then replaced by :n:`@qualid__ind` in the
+ above parser and printer types.
+
+ When :n:`@qualid__constant` is surrounded by square brackets,
+ all the implicit arguments of :n:`@qualid__constant` (whether maximally inserted or not) are ignored
+ when translating to :n:`@qualid__constructor` (i.e., before
+ applying :n:`@qualid__print`) and replaced with implicit
+ argument holes :g:`_` when translating from
+ :n:`@qualid__constructor` to :n:`@qualid__constant` (after
+ :n:`@qualid__parse`). See below for an :ref:`example <example-number-notation-implicit-args>`.
+
+ .. note::
+ The implicit status of the arguments is considered
+ only at notation declaration time, any further
+ modification of this status has no impact
+ on the previously declared notations.
+
+ .. note::
+ In case of multiple implicit options (for instance
+ :g:`Arguments eq_refl {A}%type_scope {x}, [_] _`), an
+ argument is considered implicit when it is implicit in any of the
+ options.
+
+ .. note::
+ To use a :token:`sort` as the target type :n:`@qualid__type`, use an :ref:`abbreviation <Abbreviations>`
+ as in the :ref:`example below <example-number-notation-non-inductive>`.
+
+ :n:`warning after @bignat`
displays a warning message about a possible stack
overflow when calling :n:`@qualid__parse` to parse a literal larger than :n:`@bignat`.
@@ -1599,11 +1655,11 @@ Number notations
with :n:`(warning after @bignat)`, this warning is emitted when
parsing a number greater than or equal to :token:`bignat`.
- :n:`( abstract after @bignat )`
+ :n:`abstract after @bignat`
returns :n:`(@qualid__parse m)` when parsing a literal
:n:`m` that's greater than :n:`@bignat` rather than reducing it to a normal form.
Here :g:`m` will be a
- :g:`Numeral.int`, :g:`Numeral.uint`, :g:`Z` or :g:`Numeral.numeral`, depending on the
+ :g:`Number.int`, :g:`Number.uint`, :g:`Z` or :g:`Number.number`, depending on the
type of the parsing function :n:`@qualid__parse`. This allows for a
more compact representation of literals in types such as :g:`nat`,
and limits parse failures due to stack overflow. Note that a
@@ -1617,7 +1673,7 @@ Number notations
with :n:`(abstract after @bignat)`, this warning is emitted when
parsing a number greater than or equal to :token:`bignat`.
Typically, this indicates that the fully computed representation
- of numbers can be so large that non-tail-recursive OCaml
+ of numbers can be so large that non-tail-recursive |OCaml|
functions run out of stack space when trying to walk them.
.. warn:: The 'abstract after' directive has no effect when the parsing function (@qualid__parse) targets an option type.
@@ -1625,76 +1681,94 @@ Number notations
As noted above, the :n:`(abstract after @natural)` directive has no
effect when :n:`@qualid__parse` lands in an :g:`option` type.
+ .. exn:: 'via' and 'abstract' cannot be used together.
+
+ With the :n:`abstract after` option, the parser function
+ :n:`@qualid__parse` does not reduce large numbers to a normal form,
+ which prevents doing the translation given in the :n:`mapping` list.
+
.. exn:: Cannot interpret this number as a value of type @type
- The numeral notation registered for :token:`type` does not support
+ The number notation registered for :token:`type` does not support
the given number. This error is given when the interpretation
function returns :g:`None`, or if the interpretation is registered
only for integers or non-negative integers, and the given number
has a fractional or exponent part or is negative.
- .. exn:: @qualid__parse should go from Numeral.int to @type or (option @type). Instead of Numeral.int, the types Numeral.uint or Z or Int63.int or Numeral.numeral could be used (you may need to require BinNums or Numeral or Int63 first).
+ .. exn:: @qualid__parse should go from Number.int to @type or (option @type). Instead of Number.int, the types Number.uint or Z or Int63.int or Number.number could be used (you may need to require BinNums or Number or Int63 first).
The parsing function given to the :cmd:`Number Notation`
vernacular is not of the right type.
- .. exn:: @qualid__print should go from @type to Numeral.int or (option Numeral.int). Instead of Numeral.int, the types Numeral.uint or Z or Int63.int or Numeral.numeral could be used (you may need to require BinNums or Numeral or Int63 first).
+ .. exn:: @qualid__print should go from @type to Number.int or (option Number.int). Instead of Number.int, the types Number.uint or Z or Int63.int or Number.number could be used (you may need to require BinNums or Number or Int63 first).
The printing function given to the :cmd:`Number Notation`
vernacular is not of the right type.
- .. exn:: Unexpected term @term while parsing a numeral notation.
+ .. exn:: Unexpected term @term while parsing a number notation.
Parsing functions must always return ground terms, made up of
- applications of constructors, inductive types, and primitive
+ function application, constructors, inductive type families, sorts and primitive
integers. Parsing functions may not return terms containing
axioms, bare (co)fixpoints, lambdas, etc.
- .. exn:: Unexpected non-option term @term while parsing a numeral notation.
+ .. exn:: Unexpected non-option term @term while parsing a number notation.
Parsing functions expected to return an :g:`option` must always
return a concrete :g:`Some` or :g:`None` when applied to a
concrete number expressed as a (hexa)decimal. They may not return
opaque constants.
+ .. exn:: Multiple 'via' options.
+
+ At most one :g:`via` option can be given.
+
+ .. exn:: Multiple 'warning after' or 'abstract after' options.
+
+ At most one :g:`warning after` or :g:`abstract after` option can be given.
+
.. _string-notations:
String notations
~~~~~~~~~~~~~~~~
-.. cmd:: String Notation @qualid @qualid__parse @qualid__print : @scope_name
+.. cmd:: String Notation @qualid__type @qualid__parse @qualid__print {? ( @number_string_via ) } : @scope_name
:name: String Notation
Allows the user to customize how strings are parsed and printed.
- The token :n:`@qualid` should be the name of an inductive type,
- while :n:`@qualid__parse` and :n:`@qualid__print` should be the names of the
- parsing and printing functions, respectively. The parsing function
- :n:`@qualid__parse` should have one of the following types:
+ :n:`@qualid__type`
+ the name of an inductive type,
+ while :n:`@qualid__parse` and :n:`@qualid__print` should be the names of the
+ parsing and printing functions, respectively. The parsing function
+ :n:`@qualid__parse` should have one of the following types:
+
+ * :n:`Byte.byte -> @qualid__type`
+ * :n:`Byte.byte -> option @qualid__type`
+ * :n:`list Byte.byte -> @qualid__type`
+ * :n:`list Byte.byte -> option @qualid__type`
- * :n:`Byte.byte -> @qualid`
- * :n:`Byte.byte -> option @qualid`
- * :n:`list Byte.byte -> @qualid`
- * :n:`list Byte.byte -> option @qualid`
+ The printing function :n:`@qualid__print` should have one of the
+ following types:
- The printing function :n:`@qualid__print` should have one of the
- following types:
+ * :n:`@qualid__type -> Byte.byte`
+ * :n:`@qualid__type -> option Byte.byte`
+ * :n:`@qualid__type -> list Byte.byte`
+ * :n:`@qualid__type -> option (list Byte.byte)`
- * :n:`@qualid -> Byte.byte`
- * :n:`@qualid -> option Byte.byte`
- * :n:`@qualid -> list Byte.byte`
- * :n:`@qualid -> option (list Byte.byte)`
+ When parsing, the application of the parsing function
+ :n:`@qualid__parse` to the string will be fully reduced, and universes
+ of the resulting term will be refreshed.
- When parsing, the application of the parsing function
- :n:`@qualid__parse` to the string will be fully reduced, and universes
- of the resulting term will be refreshed.
+ Note that only fully-reduced ground terms (terms containing only
+ function application, constructors, inductive type families,
+ sorts, and primitive integers) will be considered for printing.
- Note that only fully-reduced ground terms (terms containing only
- function application, constructors, inductive type families,
- sorts, and primitive integers) will be considered for printing.
+ :n:`via @qualid__ind mapping [ {+, @qualid__constant => @qualid__constructor } ]`
+ works as for :ref:`number notations above <number-string-via>`.
- .. exn:: Cannot interpret this string as a value of type @type
+ .. exn:: Cannot interpret this string as a value of type @type
The string notation registered for :token:`type` does not support
the given string. This error is given when the interpretation
@@ -1713,7 +1787,7 @@ String notations
.. exn:: Unexpected term @term while parsing a string notation.
Parsing functions must always return ground terms, made up of
- applications of constructors, inductive types, and primitive
+ function application, constructors, inductive type families, sorts and primitive
integers. Parsing functions may not return terms containing
axioms, bare (co)fixpoints, lambdas, etc.
@@ -1724,16 +1798,37 @@ String notations
concrete string expressed as a decimal. They may not return
opaque constants.
-The following errors apply to both string and numeral notations:
+.. note::
+ Number or string notations for parameterized inductive types can be
+ added by declaring an :ref:`abbreviation <Abbreviations>` for the
+ inductive which instantiates all parameters. See :ref:`example below <example-string-notation-parameterized-inductive>`.
+
+The following errors apply to both string and number notations:
.. exn:: @type is not an inductive type.
- String and numeral notations can only be declared for inductive types with no
- arguments.
+ String and number notations can only be declared for inductive types.
+ Declare string or numeral notations for non-inductive types using :n:`@number_string_via`.
+
+ .. exn:: @qualid was already mapped to @qualid and cannot be remapped to @qualid
+
+ Duplicates are not allowed in the :n:`mapping` list.
+
+ .. exn:: Missing mapping for constructor @qualid
+
+ A mapping should be provided for :n:`@qualid` in the :n:`mapping` list.
+
+ .. warn:: @type was already mapped to @type, mapping it also to @type might yield ill typed terms when using the notation.
+
+ Two pairs in the :n:`mapping` list associate types that might be incompatible.
+
+ .. warn:: Type of @qualid seems incompatible with the type of @qualid. Expected type is: @type instead of @type. This might yield ill typed terms when using the notation.
+
+ A mapping given in the :n:`mapping` list associates a constant with a seemingly incompatible constructor.
.. exn:: Cannot interpret in @scope_name because @qualid could not be found in the current environment.
- The inductive type used to register the string or numeral notation is no
+ The inductive type used to register the string or number notation is no
longer available in the environment. Most likely, this is because
the notation was declared inside a functor for an
inductive type inside the functor. This use case is not currently
@@ -1762,6 +1857,198 @@ The following errors apply to both string and numeral notations:
.. todo note on "single qualified identifiers" https://github.com/coq/coq/pull/11718#discussion_r415076703
+.. example:: Number Notation for radix 3
+
+ The following example parses and prints natural numbers
+ whose digits are :g:`0`, :g:`1` or :g:`2` as terms of the following
+ inductive type encoding radix 3 numbers.
+
+ .. coqtop:: in reset
+
+ Inductive radix3 : Set :=
+ | x0 : radix3
+ | x3 : radix3 -> radix3
+ | x3p1 : radix3 -> radix3
+ | x3p2 : radix3 -> radix3.
+
+ We first define a parsing function
+
+ .. coqtop:: in
+
+ Definition of_uint_dec (u : Decimal.uint) : option radix3 :=
+ let fix f u := match u with
+ | Decimal.Nil => Some x0
+ | Decimal.D0 u => match f u with Some u => Some (x3 u) | None => None end
+ | Decimal.D1 u => match f u with Some u => Some (x3p1 u) | None => None end
+ | Decimal.D2 u => match f u with Some u => Some (x3p2 u) | None => None end
+ | _ => None end in
+ f (Decimal.rev u).
+ Definition of_uint (u : Number.uint) : option radix3 :=
+ match u with Number.UIntDecimal u => of_uint_dec u | Number.UIntHexadecimal _ => None end.
+
+ and a printing function
+
+ .. coqtop:: in
+
+ Definition to_uint_dec (x : radix3) : Decimal.uint :=
+ let fix f x := match x with
+ | x0 => Decimal.Nil
+ | x3 x => Decimal.D0 (f x)
+ | x3p1 x => Decimal.D1 (f x)
+ | x3p2 x => Decimal.D2 (f x) end in
+ Decimal.rev (f x).
+ Definition to_uint (x : radix3) : Number.uint := Number.UIntDecimal (to_uint_dec x).
+
+ before declaring the notation
+
+ .. coqtop:: in
+
+ Declare Scope radix3_scope.
+ Open Scope radix3_scope.
+ Number Notation radix3 of_uint to_uint : radix3_scope.
+
+ We can check the printer
+
+ .. coqtop:: all
+
+ Check x3p2 (x3p1 x0).
+
+ and the parser
+
+ .. coqtop:: all
+
+ Set Printing All.
+ Check 120.
+
+ Digits other than :g:`0`, :g:`1` and :g:`2` are rejected.
+
+ .. coqtop:: all fail
+
+ Check 3.
+
+.. _example-number-notation-non-inductive:
+
+.. example:: Number Notation for a non inductive type
+
+ The following example encodes the terms in the form :g:`sum unit ( ... (sum unit unit) ... )`
+ as the number of units in the term. For instance :g:`sum unit (sum unit unit)`
+ is encoded as :g:`3` while :g:`unit` is :g:`1` and :g:`0` stands for :g:`Empty_set`.
+ The inductive :g:`I` will be used as :n:`@qualid__ind`.
+
+ .. coqtop:: in reset
+
+ Inductive I := Iempty : I | Iunit : I | Isum : I -> I -> I.
+
+ We then define :n:`@qualid__parse` and :n:`@qualid__print`
+
+ .. coqtop:: in
+
+ Definition of_uint (x : Number.uint) : I :=
+ let fix f n := match n with
+ | O => Iempty | S O => Iunit
+ | S n => Isum Iunit (f n) end in
+ f (Nat.of_num_uint x).
+
+ Definition to_uint (x : I) : Number.uint :=
+ let fix f i := match i with
+ | Iempty => O | Iunit => 1
+ | Isum i1 i2 => f i1 + f i2 end in
+ Nat.to_num_uint (f x).
+
+ Inductive sum (A : Set) (B : Set) : Set := pair : A -> B -> sum A B.
+
+ the number notation itself
+
+ .. coqtop:: in
+
+ Notation nSet := Set (only parsing).
+ Number Notation nSet of_uint to_uint (via I
+ mapping [Empty_set => Iempty, unit => Iunit, sum => Isum]) : type_scope.
+
+ and check the printer
+
+ .. coqtop:: all
+
+ Local Open Scope type_scope.
+ Check sum unit (sum unit unit).
+
+ and the parser
+
+ .. coqtop:: all
+
+ Set Printing All.
+ Check 3.
+
+.. _example-number-notation-implicit-args:
+
+.. example:: Number Notation with implicit arguments
+
+ The following example parses and prints natural numbers between
+ :g:`0` and :g:`n-1` as terms of type :g:`Fin.t n`.
+
+ .. coqtop:: all reset
+
+ Require Import Vector.
+ Print Fin.t.
+
+ Note the implicit arguments of :g:`Fin.F1` and :g:`Fin.FS`,
+ which won't appear in the corresponding inductive type.
+
+ .. coqtop:: in
+
+ Inductive I := I1 : I | IS : I -> I.
+
+ Definition of_uint (x : Number.uint) : I :=
+ let fix f n := match n with O => I1 | S n => IS (f n) end in
+ f (Nat.of_num_uint x).
+
+ Definition to_uint (x : I) : Number.uint :=
+ let fix f i := match i with I1 => O | IS n => S (f n) end in
+ Nat.to_num_uint (f x).
+
+ Declare Scope fin_scope.
+ Delimit Scope fin_scope with fin.
+ Local Open Scope fin_scope.
+ Number Notation Fin.t of_uint to_uint (via I
+ mapping [[Fin.F1] => I1, [Fin.FS] => IS]) : fin_scope.
+
+ Now :g:`2` is parsed as :g:`Fin.FS (Fin.FS Fin.F1)`, that is
+ :g:`@Fin.FS _ (@Fin.FS _ (@Fin.F1 _))`.
+
+ .. coqtop:: all
+
+ Check 2.
+
+ which can be of type :g:`Fin.t 3` (numbers :g:`0`, :g:`1` and :g:`2`)
+
+ .. coqtop:: all
+
+ Check 2 : Fin.t 3.
+
+ but cannot be of type :g:`Fin.t 2` (only :g:`0` and :g:`1`)
+
+ .. coqtop:: all fail
+
+ Check 2 : Fin.t 2.
+
+.. _example-string-notation-parameterized-inductive:
+
+.. example:: String Notation with a parameterized inductive type
+
+ The parameter :g:`Byte.byte` for the parameterized inductive type
+ :g:`list` is given through an :ref:`abbreviation <Abbreviations>`.
+
+ .. coqtop:: in reset
+
+ Notation string := (list Byte.byte) (only parsing).
+ Definition id_string := @id string.
+
+ String Notation string id_string id_string : list_scope.
+
+ .. coqtop:: all
+
+ Check "abc"%list.
+
.. _TacticNotation:
Tactic Notations
@@ -1877,12 +2164,12 @@ Tactic notations allow customizing the syntax of tactics.
- :tacn:`unfold`, :tacn:`with_strategy`
* - ``constr``
- - :token:`term`
+ - :token:`one_term`
- a term
- :tacn:`exact`
* - ``uconstr``
- - :token:`term`
+ - :token:`one_term`
- an untyped term
- :tacn:`refine`
@@ -1961,9 +2248,9 @@ Tactic notations allow customizing the syntax of tactics.
.. rubric:: Footnotes
.. [#and_or_levels] which are the levels effectively chosen in the current
- implementation of Coq
+ implementation of |Coq|
-.. [#no_associativity] Coq accepts notations declared as nonassociative 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``
+.. [#no_associativity] |Coq| accepts notations declared as nonassociative 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/sphinx/using/libraries/funind.rst b/doc/sphinx/using/libraries/funind.rst
index 738d64bfc3..93571ecebb 100644
--- a/doc/sphinx/using/libraries/funind.rst
+++ b/doc/sphinx/using/libraries/funind.rst
@@ -169,13 +169,24 @@ terminating functions.
Tactics
-------
-.. tacn:: functional induction (@qualid {+ @term})
+.. tacn:: functional induction @term {? using @one_term {? with @bindings } } {? as @simple_intropattern }
:name: functional induction
- The tactic functional induction performs case analysis and induction
- following the definition of a function. It makes use of a principle
+ Performs case analysis and induction following the definition of a function
+ :token:`qualid`, which must be fully applied to its arguments as part of
+ :token:`term`. It uses a principle
generated by :cmd:`Function` or :cmd:`Functional Scheme`.
Note that this tactic is only available after a ``Require Import FunInd``.
+ See the :cmd:`Function` command.
+
+ :n:`using @one_term`
+ Specifies the induction principle (aka elimination scheme).
+
+ :n:`with @bindings`
+ Specifies the arguments of the induction principle.
+
+ :n:`as @simple_intropattern`
+ Provides names for the introduced variables.
.. example::
@@ -189,15 +200,6 @@ Tactics
Qed.
.. note::
- :n:`(@qualid {+ @term})` must be a correct full application
- of :n:`@qualid`. In particular, the rules for implicit arguments are the
- same as usual. For example use :n:`@@qualid` if you want to write implicit
- arguments explicitly.
-
- .. note::
- Parentheses around :n:`@qualid {+ @term}` are not mandatory and can be skipped.
-
- .. note::
:n:`functional induction (f x1 x2 x3)` is actually a wrapper for
:n:`induction x1, x2, x3, (f x1 x2 x3) using @qualid` followed by a cleaning
phase, where :n:`@qualid` is the induction principle registered for :g:`f`
@@ -218,22 +220,27 @@ Tactics
.. exn:: Not the right number of induction arguments.
:undocumented:
- .. tacv:: functional induction (@qualid {+ @term}) as @simple_intropattern using @term with @bindings_list
-
- Similarly to :tacn:`induction` and :tacn:`elim`, this allows giving
- explicitly the name of the introduced variables, the induction principle, and
- the values of dependent premises of the elimination scheme, including
- *predicates* for mutual induction when :n:`@qualid` is part of a mutually
- recursive definition.
-
-.. tacn:: functional inversion @ident
+.. tacn:: functional inversion {| @ident | @natural } {? @qualid }
:name: functional inversion
- :tacn:`functional inversion` is a tactic that performs inversion on hypothesis
- :n:`@ident` of the form :n:`@qualid {+ @term} = @term` or :n:`@term = @qualid
- {+ @term}` where :n:`@qualid` must have been defined using :cmd:`Function`.
+ Performs inversion on hypothesis
+ :n:`@ident` of the form :n:`@qualid {+ @term} = @term` or
+ :n:`@term = @qualid {+ @term}` when :n:`@qualid` is defined using :cmd:`Function`.
Note that this tactic is only available after a ``Require Import FunInd``.
+ :n:`@natural`
+ Does the same thing as :n:`intros until @natural` followed by
+ :n:`functional inversion @ident` where :token:`ident` is the
+ identifier for the last introduced hypothesis.
+
+ :n:`@qualid`
+ If the hypothesis :token:`ident` (or :token:`natural`) has a type of the form
+ :n:`@qualid__1 {+ @term__i } = @qualid__2 {+ @term__j }` where
+ :n:`@qualid__1` and :n:`@qualid__2` are valid candidates to
+ functional inversion, this variant allows choosing which :token:`qualid`
+ is inverted.
+
+
.. exn:: Hypothesis @ident must contain at least one Function.
:undocumented:
@@ -242,39 +249,26 @@ Tactics
This error may be raised when some inversion lemma failed to be generated by
Function.
-
- .. tacv:: functional inversion @natural
-
- This does the same thing as :n:`intros until @natural` followed by
- :n:`functional inversion @ident` where :token:`ident` is the
- identifier for the last introduced hypothesis.
-
- .. tacv:: functional inversion @ident @qualid
- functional inversion @natural @qualid
-
- If the hypothesis :token:`ident` (or :token:`natural`) has a type of the form
- :n:`@qualid__1 {+ @term__i } = @qualid__2 {+ @term__j }` where
- :n:`@qualid__1` and :n:`@qualid__2` are valid candidates to
- functional inversion, this variant allows choosing which :token:`qualid`
- is inverted.
-
.. _functional-scheme:
Generation of induction principles with ``Functional`` ``Scheme``
-----------------------------------------------------------------
-.. cmd:: Functional Scheme @ident__0 := Induction for @ident' Sort @sort {* with @ident__i := Induction for @ident__i' Sort @sort}
+.. cmd:: Functional Scheme @func_scheme_def {* with @func_scheme_def }
+
+ .. insertprodn func_scheme_def func_scheme_def
+
+ .. prodn::
+ func_scheme_def ::= @ident := Induction for @qualid Sort @sort_family
+
+ An experimental high-level tool that
+ automatically generates induction principles corresponding to functions that
+ may be mutually recursive. The command generates an
+ induction principle named :n:`@ident` for each given function named :n:`@qualid`.
+ The :n:`@qualid`\s must be given in the same order as when they were defined.
- This command is a high-level experimental tool for
- generating automatically induction principles corresponding to
- (possibly mutually recursive) functions. First, it must be made
- available via ``Require Import FunInd``.
- Each :n:`@ident__i` is a different mutually defined function
- name (the names must be in the same order as when they were defined). This
- command generates the induction principle for each :n:`@ident__i`, following
- the recursive structure and case analyses of the corresponding function
- :n:`@ident__i'`.
+ Note the command must be made available via :cmd:`Require Import` ``FunInd``.
.. warning::
diff --git a/doc/sphinx/using/libraries/index.rst b/doc/sphinx/using/libraries/index.rst
index 0bd3054788..95218322ff 100644
--- a/doc/sphinx/using/libraries/index.rst
+++ b/doc/sphinx/using/libraries/index.rst
@@ -4,15 +4,15 @@
Libraries and plugins
=====================
-Coq is distributed with a standard library and a set of internal
+|Coq| is distributed with a standard library and a set of internal
plugins (most of which provide tactics that have already been
presented in :ref:`writing-proofs`). This chapter presents this
standard library and some of these internal plugins which provide
features that are not tactics.
-In addition, Coq has a rich ecosystem of external libraries and
+In addition, |Coq| has a rich ecosystem of external libraries and
plugins. These libraries and plugins can be browsed online through
-the `Coq Package Index <https://coq.inria.fr/opam/www/>`_ and
+the `|Coq| Package Index <https://coq.inria.fr/opam/www/>`_ and
installed with the `opam package manager
<https://coq.inria.fr/opam-using.html>`_.
diff --git a/doc/sphinx/using/libraries/writing.rst b/doc/sphinx/using/libraries/writing.rst
index 325ea2af60..724bcd0488 100644
--- a/doc/sphinx/using/libraries/writing.rst
+++ b/doc/sphinx/using/libraries/writing.rst
@@ -1,9 +1,9 @@
-Writing Coq libraries and plugins
-=================================
+Writing |Coq| libraries and plugins
+===================================
-This section presents the part of the Coq language that is useful only
-to library and plugin authors. A tutorial for writing Coq plugins is
-available in the Coq repository in `doc/plugin_tutorial
+This section presents the part of the |Coq| language that is useful only
+to library and plugin authors. A tutorial for writing |Coq| plugins is
+available in the |Coq| repository in `doc/plugin_tutorial
<https://github.com/coq/coq/tree/master/doc/plugin_tutorial>`_.
Deprecating library objects or tactics
diff --git a/doc/sphinx/using/tools/coqdoc.rst b/doc/sphinx/using/tools/coqdoc.rst
index 9ac3d2adda..88c1a575d9 100644
--- a/doc/sphinx/using/tools/coqdoc.rst
+++ b/doc/sphinx/using/tools/coqdoc.rst
@@ -253,7 +253,7 @@ The latter cannot be used around some inner parts of a proof, but can
be used around a whole proof.
Lastly, it is possible to adopt a middle-ground approach when the
-desired output is HTML, where a given snippet of Coq material is
+desired output is HTML, where a given snippet of |Coq| material is
hidden by default, but can be made visible with user interaction.
::
@@ -358,11 +358,11 @@ Command line options
**Hyperlink options**
:--glob-from file: Make references using |Coq| globalizations from file
- file. (Such globalizations are obtained with Coq option ``-dump-glob``).
+ file. (Such globalizations are obtained with |Coq| option ``-dump-glob``).
:--no-externals: Do not insert links to the |Coq| standard library.
:--external url coqdir: Use given URL for linking references whose
name starts with prefix ``coqdir``.
- :--coqlib url: Set base URL for the Coq standard library (default is
+ :--coqlib url: Set base URL for the |Coq| standard library (default is
`<http://coq.inria.fr/library/>`_). This is equivalent to ``--external url
Coq``.
:-R dir coqdir: Recursively map physical directory dir to |Coq| logical
diff --git a/doc/sphinx/using/tools/index.rst b/doc/sphinx/using/tools/index.rst
index dfe38dfce9..8543c5de8a 100644
--- a/doc/sphinx/using/tools/index.rst
+++ b/doc/sphinx/using/tools/index.rst
@@ -5,11 +5,11 @@ Command-line and graphical tools
================================
This chapter presents the command-line tools that users will need to
-build their Coq project, the documentation of the CoqIDE standalone
+build their |Coq| project, the documentation of the |CoqIDE| standalone
user interface and the documentation of the parallel proof processing
-feature that is supported by CoqIDE and several other user interfaces.
-A list of available user interfaces to interact with Coq is available
-on the `Coq website <https://coq.inria.fr/user-interfaces.html>`_.
+feature that is supported by |CoqIDE| and several other user interfaces.
+A list of available user interfaces to interact with |Coq| is available
+on the `|Coq| website <https://coq.inria.fr/user-interfaces.html>`_.
.. toctree::
:maxdepth: 1