aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/sphinx/addendum/generalized-rewriting.rst72
-rw-r--r--doc/sphinx/proof-engine/ltac2.rst4
-rw-r--r--doc/tools/docgram/common.edit_mlg2
-rw-r--r--doc/tools/docgram/fullGrammar2
-rw-r--r--doc/tools/docgram/orderedGrammar2
5 files changed, 56 insertions, 26 deletions
diff --git a/doc/sphinx/addendum/generalized-rewriting.rst b/doc/sphinx/addendum/generalized-rewriting.rst
index c54db36691..9ac05fab2e 100644
--- a/doc/sphinx/addendum/generalized-rewriting.rst
+++ b/doc/sphinx/addendum/generalized-rewriting.rst
@@ -726,6 +726,30 @@ declare your constant as rigid for proof search using the command
Strategies for rewriting
------------------------
+Usage
+~~~~~
+
+.. tacn:: rewrite_strat @rewstrategy {? in @ident }
+ :name: rewrite_strat
+
+ Rewrite using :n:`@rewstrategy` in the conclusion or in the hypothesis :n:`@ident`.
+
+ .. exn:: Nothing to rewrite.
+
+ The strategy didn't find any matches.
+
+ .. exn:: No progress made.
+
+ If the strategy succeeded but made no progress.
+
+ .. exn:: Unable to satisfy the rewriting constraints.
+
+ If the strategy succeeded and made progress but the
+ corresponding rewriting constraints are not satisfied.
+
+ :tacn:`setoid_rewrite` :n:`@one_term` is basically equivalent to
+ :n:`rewrite_strat outermost @one_term`.
+
Definitions
~~~~~~~~~~~
@@ -773,7 +797,7 @@ are applied using the tactic :n:`rewrite_strat @rewstrategy`.
failure
:n:`id`
- identity
+ identity
:n:`refl`
reflexivity
@@ -803,10 +827,16 @@ are applied using the tactic :n:`rewrite_strat @rewstrategy`.
all subterms
:n:`innermost @rewstrategy`
- innermost first
+ Innermost first.
+ When there are multiple nested matches in a subterm, the innermost subterm
+ is rewritten. For :ref:`example <rewrite_strat_innermost_outermost>`,
+ rewriting :n:`(a + b) + c` with Nat.add_comm gives :n:`(b + a) + c`.
:n:`outermost @rewstrategy`
- outermost first
+ Outermost first.
+ When there are multiple nested matches in a subterm, the outermost subterm
+ is rewritten. For :ref:`example <rewrite_strat_innermost_outermost>`,
+ rewriting :n:`(a + b) + c` with Nat.add_comm gives :n:`c + (a + b)`.
:n:`bottomup @rewstrategy`
bottom-up
@@ -833,8 +863,8 @@ are applied using the tactic :n:`rewrite_strat @rewstrategy`.
to be documented
-A few of these are defined in terms of the others using a
-primitive fixpoint operator:
+Conceptually, a few of these are defined in terms of the others using a
+primitive fixpoint operator `fix`, which the tactic doesn't currently support:
- :n:`try @rewstrategy := choice @rewstrategy id`
- :n:`any @rewstrategy := fix @ident. try (@rewstrategy ; @ident)`
@@ -876,30 +906,30 @@ if it reduces the subterm under consideration. The ``fold`` strategy takes
a :token:`term` and tries to *unify* it to the current subterm, converting it to :token:`term`
on success. It is stronger than the tactic ``fold``.
+.. _rewrite_strat_innermost_outermost:
-Usage
-~~~~~
-
-
-.. tacn:: rewrite_strat @rewstrategy {? in @ident }
- :name: rewrite_strat
+.. example:: :n:`innermost` and :n:`outermost`
- Rewrite using the strategy s in hypothesis ident or the conclusion.
+ The type of `Nat.add_comm` is `forall n m : nat, n + m = m + n`.
- .. exn:: Nothing to rewrite.
+ .. coqtop:: all
- If the strategy failed.
+ Require Import Coq.Arith.Arith.
+ Set Printing Parentheses.
+ Goal forall a b c: nat, a + b + c = 0.
+ rewrite_strat innermost Nat.add_comm.
- .. exn:: No progress made.
+ .. coqtop:: none
- If the strategy succeeded but made no progress.
+ Abort.
+ Goal forall a b c: nat, a + b + c = 0.
- .. exn:: Unable to satisfy the rewriting constraints.
+ Using :n:`outermost` instead gives this result:
- If the strategy succeeded and made progress but the
- corresponding rewriting constraints are not satisfied.
+ .. coqtop:: all
+ rewrite_strat outermost Nat.add_comm.
- The ``setoid_rewrite c`` tactic is basically equivalent to
- ``rewrite_strat (outermost c)``.
+ .. coqtop:: none
+ Abort.
diff --git a/doc/sphinx/proof-engine/ltac2.rst b/doc/sphinx/proof-engine/ltac2.rst
index 3646a32a79..1bb4216e4f 100644
--- a/doc/sphinx/proof-engine/ltac2.rst
+++ b/doc/sphinx/proof-engine/ltac2.rst
@@ -554,7 +554,7 @@ Built-in quotations
ltac2_quotations ::= ident : ( @lident )
| constr : ( @term )
| open_constr : ( @term )
- | pattern : ( @cpattern )
+ | pat : ( @cpattern )
| reference : ( {| & @ident | @qualid } )
| ltac1 : ( @ltac1_expr_in_env )
| ltac1val : ( @ltac1_expr_in_env )
@@ -568,7 +568,7 @@ The current implementation recognizes the following built-in quotations:
(type ``Init.constr``).
- ``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
+- ``pat``, 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,
diff --git a/doc/tools/docgram/common.edit_mlg b/doc/tools/docgram/common.edit_mlg
index 44bb767011..8aeb2e564d 100644
--- a/doc/tools/docgram/common.edit_mlg
+++ b/doc/tools/docgram/common.edit_mlg
@@ -2066,7 +2066,7 @@ ltac2_tactic_atom: [
| MOVETO ltac2_quotations "constr" ":" "(" lconstr ")" (* Ltac2 plugin *)
| MOVETO ltac2_quotations "open_constr" ":" "(" lconstr ")" (* Ltac2 plugin *)
| MOVETO ltac2_quotations "ident" ":" "(" lident ")" (* Ltac2 plugin *)
-| MOVETO ltac2_quotations "pattern" ":" "(" cpattern ")" (* Ltac2 plugin *)
+| MOVETO ltac2_quotations "pat" ":" "(" cpattern ")" (* Ltac2 plugin *)
| MOVETO ltac2_quotations "reference" ":" "(" globref ")" (* Ltac2 plugin *)
| MOVETO ltac2_quotations "ltac1" ":" "(" ltac1_expr_in_env ")" (* Ltac2 plugin *)
| MOVETO ltac2_quotations "ltac1val" ":" "(" ltac1_expr_in_env ")" (* Ltac2 plugin *)
diff --git a/doc/tools/docgram/fullGrammar b/doc/tools/docgram/fullGrammar
index 9f2559ffbc..ec23ffe83e 100644
--- a/doc/tools/docgram/fullGrammar
+++ b/doc/tools/docgram/fullGrammar
@@ -3370,7 +3370,7 @@ G_LTAC2_tactic_atom: [
| "constr" ":" "(" Constr.lconstr ")" (* Ltac2 plugin *)
| "open_constr" ":" "(" Constr.lconstr ")" (* Ltac2 plugin *)
| "ident" ":" "(" lident ")" (* Ltac2 plugin *)
-| "pattern" ":" "(" Constr.cpattern ")" (* Ltac2 plugin *)
+| "pat" ":" "(" Constr.cpattern ")" (* Ltac2 plugin *)
| "reference" ":" "(" globref ")" (* Ltac2 plugin *)
| "ltac1" ":" "(" ltac1_expr_in_env ")" (* Ltac2 plugin *)
| "ltac1val" ":" "(" ltac1_expr_in_env ")" (* Ltac2 plugin *)
diff --git a/doc/tools/docgram/orderedGrammar b/doc/tools/docgram/orderedGrammar
index b53af609ec..75b32a5800 100644
--- a/doc/tools/docgram/orderedGrammar
+++ b/doc/tools/docgram/orderedGrammar
@@ -2378,7 +2378,7 @@ ltac2_quotations: [
| "ident" ":" "(" lident ")"
| "constr" ":" "(" term ")"
| "open_constr" ":" "(" term ")"
-| "pattern" ":" "(" cpattern ")"
+| "pat" ":" "(" cpattern ")"
| "reference" ":" "(" [ "&" ident | qualid ] ")"
| "ltac1" ":" "(" ltac1_expr_in_env ")"
| "ltac1val" ":" "(" ltac1_expr_in_env ")"