Skip to content

Commit

Permalink
Merge PR #12927: Explain that tactics applied to multiple goals don't…
Browse files Browse the repository at this point in the history
… preserve the order

Reviewed-by: Zimmi48
Ack-by: chdoc
Ack-by: jfehrle
  • Loading branch information
coqbot-app[bot] committed Sep 8, 2020
2 parents dde607c + f238af8 commit ebcfaf6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
23 changes: 21 additions & 2 deletions doc/sphinx/proof-engine/ltac.rst
Expand Up @@ -375,8 +375,14 @@ behavior.)
| !
| par
Applies :token:`ltac_expr` to the selected goals. It can only be used at the top
level of a tactic expression; it cannot be used within a tactic expression.
Reorders the goals and applies :token:`ltac_expr` to the selected goals. It can
only be used at the top level of a tactic expression; it cannot be used within a
tactic expression. The selected goals are reordered so they appear after the
lowest-numbered selected goal, ordered by goal number. :ref:`Example
<reordering_goals_ex>`. If the selector applies
to a single goal or to all goals, the reordering will not be apparent. The order of
the goals in the :token:`selector` is irrelevant. (This may not be what you expect;
see `#8481 <https://github.com/coq/coq/issues/8481>`_.)

.. todo why shouldn't "all" and "!" be accepted anywhere a @selector is accepted?
It would be simpler to explain.
Expand Down Expand Up @@ -430,6 +436,19 @@ Selectors can also be used nested within a tactic expression with the
:name: No such goal. (Goal selector)
:undocumented:

.. _reordering_goals_ex:

.. example:: Selector reordering goals

.. coqtop:: reset in

Goal 1=0 /\ 2=0 /\ 3=0.

.. coqtop:: all

repeat split.
1,3: idtac.

.. TODO change error message index entry
Expand Down
24 changes: 16 additions & 8 deletions doc/sphinx/proof-engine/tactics.rst
Expand Up @@ -54,7 +54,7 @@ Invocation of tactics
~~~~~~~~~~~~~~~~~~~~~

A tactic is applied as an ordinary command. It may be preceded by a
goal selector (see Section :ref:`ltac-semantics`). If no selector is
goal selector (see Section :ref:`goal-selectors`). If no selector is
specified, the default selector is used.

.. _tactic_invocation_grammar:
Expand Down Expand Up @@ -4751,9 +4751,13 @@ Non-logical tactics
.. tacn:: cycle @num
:name: cycle

This tactic puts the :n:`@num` first goals at the end of the list of goals.
If :n:`@num` is negative, it will put the last :math:`|num|` goals at the
Reorders the selected goals so that the first :n:`@num` goals appear after the
other selected goals.
If :n:`@num` is negative, it puts the last :n:`@num` 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::

Expand All @@ -4771,10 +4775,12 @@ Non-logical tactics
.. tacn:: swap @num @num
:name: swap

This tactic switches the position of the goals of indices :n:`@num` and
:n:`@num`. Negative values for:n:`@num` indicate counting goals
backward from the end of the focused goal list. Goals are indexed from 1,
there is no goal with position 0.
Exchanges the position of the specified goals.
Negative values for :n:`@num` 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::

Expand All @@ -4788,7 +4794,9 @@ Non-logical tactics
.. tacn:: revgoals
:name: revgoals

This tactics reverses the list of the focused goals.
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::

Expand Down

0 comments on commit ebcfaf6

Please sign in to comment.