aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/changelog/04-tactics/12129-add-with-strategy.rst4
-rw-r--r--doc/changelog/04-tactics/12146-master+fix10812-subst-failure-section-variables.rst9
-rw-r--r--doc/changelog/05-tactic-language/12254-wit-ref-dyn.rst5
-rw-r--r--doc/changelog/10-standard-library/11249-ollibs-list-changelog.rst7
-rw-r--r--doc/changelog/10-standard-library/12008-ollibs-bool.rst2
-rw-r--r--doc/changelog/10-standard-library/12162-bool-leb.rst4
-rw-r--r--doc/changelog/10-standard-library/12237-list-more-filter-incl.rst4
-rw-r--r--doc/sphinx/proof-engine/tactics.rst142
-rw-r--r--doc/sphinx/proof-engine/vernacular-commands.rst4
-rw-r--r--doc/sphinx/user-extensions/syntax-extensions.rst41
-rw-r--r--doc/tools/docgram/common.edit_mlg4
-rw-r--r--doc/tools/docgram/fullGrammar21
-rw-r--r--doc/tools/docgram/orderedGrammar6
13 files changed, 225 insertions, 28 deletions
diff --git a/doc/changelog/04-tactics/12129-add-with-strategy.rst b/doc/changelog/04-tactics/12129-add-with-strategy.rst
new file mode 100644
index 0000000000..68558c0cf4
--- /dev/null
+++ b/doc/changelog/04-tactics/12129-add-with-strategy.rst
@@ -0,0 +1,4 @@
+- **Added:**
+ New tactical :tacn:`with_strategy` added which behaves like the
+ command :cmd:`Strategy`, with effects local to the given tactic
+ (`#12129 <https://github.com/coq/coq/pull/12129>`_, by Jason Gross).
diff --git a/doc/changelog/04-tactics/12146-master+fix10812-subst-failure-section-variables.rst b/doc/changelog/04-tactics/12146-master+fix10812-subst-failure-section-variables.rst
new file mode 100644
index 0000000000..055006d3b4
--- /dev/null
+++ b/doc/changelog/04-tactics/12146-master+fix10812-subst-failure-section-variables.rst
@@ -0,0 +1,9 @@
+- **Changed:**
+ Tactic :tacn:`subst` :n:`@ident` now fails over a section variable which is
+ indirectly dependent in the goal; the incompatibility can generally
+ be fixed by first clearing the hypotheses causing an indirect
+ dependency, as reported by the error message, or by using :tacn:`rewrite` :n:`in *`
+ instead; similarly, :tacn:`subst` has no more effect on such variables
+ (`#12146 <https://github.com/coq/coq/pull/12146>`_,
+ by Hugo Herbelin; fixes `#10812 <https://github.com/coq/coq/pull/10812>`_;
+ fixes `#12139 <https://github.com/coq/coq/pull/12139>`_).
diff --git a/doc/changelog/05-tactic-language/12254-wit-ref-dyn.rst b/doc/changelog/05-tactic-language/12254-wit-ref-dyn.rst
new file mode 100644
index 0000000000..69632fd202
--- /dev/null
+++ b/doc/changelog/05-tactic-language/12254-wit-ref-dyn.rst
@@ -0,0 +1,5 @@
+- **Changed:**
+ The "reference" tactic generic argument now accepts arbitrary
+ variables of the goal context
+ (`#12254 <https://github.com/coq/coq/pull/12254>`_,
+ by Pierre-Marie Pédrot).
diff --git a/doc/changelog/10-standard-library/11249-ollibs-list-changelog.rst b/doc/changelog/10-standard-library/11249-ollibs-list-changelog.rst
index be15fbf8f5..be54e45808 100644
--- a/doc/changelog/10-standard-library/11249-ollibs-list-changelog.rst
+++ b/doc/changelog/10-standard-library/11249-ollibs-list-changelog.rst
@@ -7,11 +7,12 @@
- properties of ``remove``: ``remove_cons``, ``remove_app``, ``notin_remove``, ``in_remove``, ``in_in_remove``, ``remove_remove_comm``, ``remove_remove_eq``, ``remove_length_le``, ``remove_length_lt``
- properties of ``concat``: ``in_concat``, ``remove_concat``
- properties of ``map`` and ``flat_map``: ``map_last``, ``map_eq_cons``, ``map_eq_app``, ``flat_map_app``, ``flat_map_ext``, ``nth_nth_nth_map``
- - properties of ``incl``: ``incl_nil_l``, ``incl_l_nil``, ``incl_cons_inv``, ``incl_app_app``, ``incl_app_inv``, ``remove_incl``
+ - properties of ``incl``: ``incl_nil_l``, ``incl_l_nil``, ``incl_cons_inv``, ``incl_app_app``, ``incl_app_inv``, ``remove_incl``, ``incl_map``, ``incl_filter``, ``incl_Forall_in_iff``
+ - properties of ``NoDup`` and ``nodup``: ``NoDup_rev``, ``NoDup_filter``, ``nodup_incl``
- properties of ``Exists`` and ``Forall``: ``Exists_nth``, ``Exists_app``, ``Exists_rev``, ``Exists_fold_right``, ``incl_Exists``, ``Forall_nth``, ``Forall_app``, ``Forall_elt``, ``Forall_rev``, ``Forall_fold_right``, ``incl_Forall``, ``map_ext_Forall``, ``Exists_or``, ``Exists_or_inv``, ``Forall_and``, ``Forall_and_inv``, ``exists_Forall``, ``Forall_image``, ``concat_nil_Forall``, ``in_flat_map_Exists``, ``notin_flat_map_Forall``
- properties of ``repeat``: ``repeat_cons``, ``repeat_to_concat``
- definitions and properties of ``list_sum`` and ``list_max``: ``list_sum_app``, ``list_max_app``, ``list_max_le``, ``list_max_lt``
- - misc: ``elt_eq_unit``, ``last_length``, ``rev_eq_app``, ``removelast_firstn_len``, ``NoDup_rev``, ``nodup_incl``, ``cons_seq``, ``seq_S``
+ - misc: ``elt_eq_unit``, ``last_length``, ``rev_eq_app``, ``removelast_firstn_len``, ``cons_seq``, ``seq_S``
- (`#11249 <https://github.com/coq/coq/pull/11249>`_,
+ (`#11249 <https://github.com/coq/coq/pull/11249>`_, `#12237 <https://github.com/coq/coq/pull/12237>`_,
by Olivier Laurent).
diff --git a/doc/changelog/10-standard-library/12008-ollibs-bool.rst b/doc/changelog/10-standard-library/12008-ollibs-bool.rst
index 7c10d261a7..42e5eb96eb 100644
--- a/doc/changelog/10-standard-library/12008-ollibs-bool.rst
+++ b/doc/changelog/10-standard-library/12008-ollibs-bool.rst
@@ -1,5 +1,5 @@
- **Added:**
- Order relations ``ltb`` and ``compareb`` added in ``Bool.Bool``.
+ Order relations ``lt`` and ``compare`` added in ``Bool.Bool``.
Order properties for ``bool`` added in ``Bool.BoolOrder`` as well as two modules ``Bool_as_OT`` and ``Bool_as_DT`` in ``Structures.OrdersEx``
(`#12008 <https://github.com/coq/coq/pull/12008>`_,
by Olivier Laurent).
diff --git a/doc/changelog/10-standard-library/12162-bool-leb.rst b/doc/changelog/10-standard-library/12162-bool-leb.rst
new file mode 100644
index 0000000000..6a4070a82e
--- /dev/null
+++ b/doc/changelog/10-standard-library/12162-bool-leb.rst
@@ -0,0 +1,4 @@
+- **Deprecated:**
+ ``Bool.leb`` in favor of ``Bool.le``. The definition of ``Bool.le`` is made local to avoid conflicts with ``Nat.le``. As a consequence, previous calls to ``leb`` based on importing ``Bool`` should now be qualified into ``Bool.le`` even if ``Bool`` is imported.
+ (`#12162 <https://github.com/coq/coq/pull/12162>`_,
+ by Olivier Laurent).
diff --git a/doc/changelog/10-standard-library/12237-list-more-filter-incl.rst b/doc/changelog/10-standard-library/12237-list-more-filter-incl.rst
deleted file mode 100644
index 37aaf697b5..0000000000
--- a/doc/changelog/10-standard-library/12237-list-more-filter-incl.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-- **Added:**
- new lemmas in ``List``: ``incl_map``, ``incl_filter``, ``NoDup_filter``, ``incl_Forall_in_iff``
- (`#12237 <https://github.com/coq/coq/pull/12237>`_,
- by Olivier Laurent).
diff --git a/doc/sphinx/proof-engine/tactics.rst b/doc/sphinx/proof-engine/tactics.rst
index 8989dd29ab..439f7fb9f6 100644
--- a/doc/sphinx/proof-engine/tactics.rst
+++ b/doc/sphinx/proof-engine/tactics.rst
@@ -2832,6 +2832,11 @@ simply :g:`t=u` dropping the implicit type of :g:`t` and :g:`u`.
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.
@@ -2845,9 +2850,11 @@ simply :g:`t=u` dropping the implicit type of :g:`t` and :g:`u`.
.. tacv:: subst
- This applies subst repeatedly from top to bottom to all identifiers of the
+ 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``.
+ 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
@@ -2873,6 +2880,15 @@ simply :g:`t=u` dropping the implicit type of :g:`t` and :g:`u`.
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
@@ -3355,6 +3371,128 @@ the conversion in hypotheses :n:`{+ @ident}`.
This is the most general syntax that combines the different variants.
+.. tacn:: with_strategy @strategy_level_or_var [ {+ @smart_qualid } ] @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.
+
+ .. note::
+
+ This tactic unfortunately does not yet play well with tactic
+ internalization, resulting in interpretation-time errors when
+ you try to use it directly with opaque identifiers, as seen in
+ the first (failing) use of :tacn:`with_strategy` in the
+ following example. This can be worked around by binding the
+ identifier to an |Ltac| variable, and this issue should
+ disappear in a future version of |Coq|; see `#12179
+ <https://github.com/coq/coq/issues/12179>`_.
+
+ .. example::
+
+ .. coqtop:: all reset abort
+
+ Opaque id.
+ Goal id 10 = 10.
+ Fail unfold id.
+ Fail with_strategy transparent [id] unfold id.
+ let id' := id in 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/sphinx/proof-engine/vernacular-commands.rst b/doc/sphinx/proof-engine/vernacular-commands.rst
index 1759264e87..7191444bac 100644
--- a/doc/sphinx/proof-engine/vernacular-commands.rst
+++ b/doc/sphinx/proof-engine/vernacular-commands.rst
@@ -817,13 +817,15 @@ described first.
.. cmd:: Strategy {+ @strategy_level [ {+ @smart_qualid } ] }
- .. insertprodn strategy_level strategy_level
+ .. insertprodn strategy_level strategy_level_or_var
.. prodn::
strategy_level ::= opaque
| @int
| expand
| transparent
+ strategy_level_or_var ::= @strategy_level
+ | @ident
This command accepts the :attr:`local` attribute, which limits its effect
to the current section or module, in which case the section and module
diff --git a/doc/sphinx/user-extensions/syntax-extensions.rst b/doc/sphinx/user-extensions/syntax-extensions.rst
index d72409e0d9..ea5ad79a80 100644
--- a/doc/sphinx/user-extensions/syntax-extensions.rst
+++ b/doc/sphinx/user-extensions/syntax-extensions.rst
@@ -1714,6 +1714,11 @@ Tactic notations allow customizing the syntax of tactics.
- a global reference of term
- :tacn:`unfold`
+ * - ``smart_global``
+ - :token:`smart_qualid`
+ - a global reference of term
+ - :tacn:`with_strategy`
+
* - ``constr``
- :token:`term`
- a term
@@ -1734,6 +1739,16 @@ Tactic notations allow customizing the syntax of tactics.
- an integer
- :tacn:`do`
+ * - ``strategy_level``
+ - :token:`strategy_level`
+ - a strategy level
+ -
+
+ * - ``strategy_level_or_var``
+ - :token:`strategy_level_or_var`
+ - a strategy level
+ - :tacn:`with_strategy`
+
* - ``tactic``
- :token:`ltac_expr`
- a tactic
@@ -1766,18 +1781,24 @@ Tactic notations allow customizing the syntax of tactics.
.. todo: notation doesn't support italics
- .. note:: In order to be bound in tactic definitions, each syntactic
- entry for argument type must include the case of a simple |Ltac|
- identifier as part of what it parses. This is naturally the case for
- ``ident``, ``simple_intropattern``, ``reference``, ``constr``, ... but not for ``integer``.
- This is the reason for introducing a special entry ``int_or_var`` which
- evaluates to integers only but which syntactically includes
+ .. note:: In order to be bound in tactic definitions, each
+ syntactic entry for argument type must include the case
+ of a simple |Ltac| identifier as part of what it
+ parses. This is naturally the case for ``ident``,
+ ``simple_intropattern``, ``reference``, ``constr``, ...
+ but not for ``integer`` nor for ``strategy_level``. This
+ is the reason for introducing special entries
+ ``int_or_var`` and ``strategy_level_or_var`` which
+ evaluate to integers or strategy levels only,
+ respectively, but which syntactically includes
identifiers in order to be usable in tactic definitions.
- .. note:: The *entry*\ ``_list*`` and ``ne_``\ *entry*\ ``_list*`` entries can be used in
- primitive tactics or in other notations at places where a list of the
- underlying entry can be used: entry is either ``constr``, ``hyp``, ``integer``
- or ``int_or_var``.
+ .. note:: The *entry*\ ``_list*`` and ``ne_``\ *entry*\ ``_list*``
+ entries can be used in primitive tactics or in other
+ notations at places where a list of the underlying entry
+ can be used: entry is either ``constr``, ``hyp``,
+ ``integer``, ``smart_qualid``, ``strategy_level``,
+ ``strategy_level_or_var``, or ``int_or_var``.
.. rubric:: Footnotes
diff --git a/doc/tools/docgram/common.edit_mlg b/doc/tools/docgram/common.edit_mlg
index c7e3ee18ad..62cc8ea86b 100644
--- a/doc/tools/docgram/common.edit_mlg
+++ b/doc/tools/docgram/common.edit_mlg
@@ -1839,3 +1839,7 @@ sentence: [
document: [
| LIST0 sentence
]
+
+strategy_level: [
+| DELETE strategy_level0
+]
diff --git a/doc/tools/docgram/fullGrammar b/doc/tools/docgram/fullGrammar
index 4274dccb40..92e9df51d5 100644
--- a/doc/tools/docgram/fullGrammar
+++ b/doc/tools/docgram/fullGrammar
@@ -451,6 +451,14 @@ bar_cbrace: [
| test_pipe_closedcurly "|" "}"
]
+strategy_level: [
+| "expand"
+| "opaque"
+| integer
+| "transparent"
+| strategy_level0
+]
+
vernac_toplevel: [
| "Drop" "."
| "Quit" "."
@@ -1213,13 +1221,6 @@ more_implicits_block: [
| "{" LIST1 name "}"
]
-strategy_level: [
-| "expand"
-| "opaque"
-| integer
-| "transparent"
-]
-
instance_name: [
| ident_decl binders
|
@@ -1598,6 +1599,7 @@ simple_tactic: [
| "guard" test
| "decompose" "[" LIST1 constr "]" constr
| "optimize_heap"
+| "with_strategy" strategy_level_or_var "[" LIST1 smart_global "]" tactic3
| "eassumption"
| "eexact" constr
| "trivial" auto_using hintbases
@@ -1855,6 +1857,11 @@ test_lpar_id_colon: [
| local_test_lpar_id_colon
]
+strategy_level_or_var: [
+| strategy_level
+| identref
+]
+
comparison: [
| "="
| "<"
diff --git a/doc/tools/docgram/orderedGrammar b/doc/tools/docgram/orderedGrammar
index df4e5a22e3..11f06b7b8a 100644
--- a/doc/tools/docgram/orderedGrammar
+++ b/doc/tools/docgram/orderedGrammar
@@ -659,6 +659,11 @@ strategy_level: [
| "transparent"
]
+strategy_level_or_var: [
+| strategy_level
+| ident
+]
+
reserv_list: [
| LIST1 ( "(" simple_reserv ")" )
| simple_reserv
@@ -1234,6 +1239,7 @@ simple_tactic: [
| "guard" int_or_var comparison int_or_var
| "decompose" "[" LIST1 one_term "]" one_term
| "optimize_heap"
+| "with_strategy" strategy_level_or_var "[" LIST1 smart_qualid "]" ltac_expr3
| "start" "ltac" "profiling"
| "stop" "ltac" "profiling"
| "reset" "ltac" "profile"