7.5 Conversion tactics
This set of tactics implements different specialized usages of the
tactic Change.
7.5.1 Cbv flag1 ... flagn, Lazy flag1
... flagn and Compute
These parameterized reduction tactics apply to any goal and perform
the normalization of the goal according to the specified flags. Since
the reduction considered in Coq include b (reduction of
functional application), d (unfolding
of transparent constants, see 5.2.5),
i (reduction of Cases, Fix and CoFix expressions) and z (removal of local definitions), every flag is one of Beta, Delta,
Iota, Zeta, [qualid1...qualidk] and
-[qualid1...qualidk].
The last two flags give the list of constants to unfold, or the list
of constants not to unfold. These two
flags can occur only after the Delta flag.
For these tactics, the Delta flag does not apply to
variables bound by a let-in construction of which the unfolding is
controlled by the Zeta flag only.
In addition, there is a flag Evar to perform instantiation of exitential variables (``?'') when an instantiation actually exists.
The goal may be
normalized with two strategies: lazy (Lazy tactic), or
call-by-value (Cbv tactic).
Notice that, for these tactics, the Delta flag without rest should be understood as unfolding all
The lazy strategy is a call-by-need strategy, with sharing of
reductions: the arguments of a function call are partially evaluated
only when necessary, but if an argument is used several times, it is
computed only once. This reduction is efficient for reducing
expressions with dead code. For instance, the proofs of a proposition
$T x. P(x) reduce to a pair of a witness t, and a proof
that t verifies the predicate P. Most of the time, t may be
computed without computing the proof of 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 evaluated first, using a weak
reduction (no reduction under the l-abstractions). Despite the
lazy strategy always performs fewer reductions than the call-by-value
strategy, the latter should be preferred for evaluating purely
computational expressions (i.e. with few dead code).
Variants:
-
Compute
This tactic is an alias for Cbv Beta Delta Evar Iota Zeta.
Error messages:
-
Delta must be specified before
A list of constants appeared before the Delta flag.
7.5.2 Red
This tactic applies to a goal which have form (x:T1)...(xk:Tk)(c
t1 ... tn) where c is a constant. If c is transparent
then it replaces c with its definition (say t) and then
reduces (t t1 ... tn) according to bi-reduction rules.
Error messages:
-
Not reducible
7.5.3 Hnf
This tactic applies to any goal. It replaces the current goal with its
head normal form according to the bdi-reduction
rules. Hnf does not produce a real head normal form but either a
product or an applicative term in head normal form or a variable.
Example: The term (n:nat)(plus (S n) (S n))
is not reduced by Hnf.
Remark: The d rule will only be applied to transparent constants
(i.e. which have not been frozen with an Opaque command; see
section 5.2.4).
7.5.4 Simpl
This tactic applies to any goal. The
tactic Simpl first applies bi-reduction rule.
Then it expands transparent constants and tries to reduce T'
according, once more, to
bi rules. But when the i rule is not applicable then
possible d-reductions are not applied. For instance trying to
use Simpl on (plus n O)=n will change nothing.
7.5.5 Unfold qualid
This tactic applies to any goal. The argument qualid must denote
a defined transparent constant or local definition (see section
1.3.2 and 5.2.5).
The tactic Unfold applies the
d rule to each occurrence of the constant to which qualid refers
in the current goal and
then replaces it with its bi-normal form.
Error messages:
-
qualid does not denote an evaluable constant
is printed.
Variants:
-
Unfold qualid1 ... qualidn
Replaces simultaneously qualid1, ..., qualidn with
their definitions and replaces the current goal with its
bi normal form.
- Unfold num11 ... numi1 qualid1 ... num1n
... numjn qualidn
The lists num11, ..., numi1 and num1n, ..., numjn
are to specify the occurrences of qualid1, ..., qualidn to be
unfolded. Occurrences are located from left to right in the linear
notation of terms.
Error message: bad occurrence numbers of qualidi
7.5.6 Fold term
This tactic applies to any goal. term is reduced using the Red
tactic. Every occurrence of the resulting term in the goal is then
substituted for term.
Variants:
-
Fold term1 ... termn
Equivalent to Fold term1;...; Fold termn.
7.5.7 Pattern term
This command applies to any goal. The argument term must be a free
subterm of the current goal. The command Pattern performs
b-expansion (the inverse of b-reduction)
of the current goal (say T) by
-
replacing all occurrences of term in T with a fresh variable
- abstracting this variable
- applying the abstracted goal to term
For instance, if the current goal T is (P t) when t does not occur in
P then Pattern t transforms it into ([x:A](P x) t). This
command has to be used, for instance, when an Apply command
fails on matching.
Variants:
-
Pattern num1 ... numn term
Only the occurrences num1 ... numn of term will be
considered for b-expansion. Occurrences are located from left
to right.
- Pattern num11 ... numn11 term1 ...num1m ... numnmm termm
Will process occurrences num11, ..., numi1 of term1,
..., num1m, ..., numjm of termm starting from termm.
Starting from a goal (P t1... tm) with the ti which do not occur in P, the tactic Pattern
t1... tm generates the equivalent goal ([x1:A1]... [xm:Am](P x1... xm)
t1... tm).
If ti occurs in one of the generated types Aj these
occurrences will also be considered and possibly abstracted.
7.5.8 Conversion tactics applied to hypotheses
conv_tactic in ident1 ... identn
Applies the conversion tactic conv_tactic to the
hypotheses ident1, ..., identn. The tactic conv_tactic is
any of the conversion tactics listed in this section.
Error messages:
-
No such hypothesis : ident.