Some tips, tricks, and features in Coq that are hard to discover.
If you have a trick you've found useful feel free to submit an issue or pull request!
pattern
tacticlazymatch
for better error messagesSearch
vernacular variantsdeex
tactic::=
to re-define Ltaclearn
approach - see Clément's thesis- tactics in terms
ltac:(eauto)
for argument to proof
unshelve
tactical, especially useful with an eapply - good example use case is constructing an object by refinement where the obligations end up being your proofs with the values as evars, when you wanted to construct the values by proofSearch s -Learnt
for a search of local hypotheses excluding Learntunfold "+"
worksdestruct matches
tactic- maximally inserted implicit arguments are implicit even when for identifier alone (eg,
nil
is defined to include the implicit list element type) - maximally inserted arguments can be defined differently for different numbers of arguments - undocumented but
eq_refl
provides an example - using instantiate to modify evar environment (thanks to Jonathan Leivent on coq-club)
- strong induction is in the standard library:
Require Import Arith Wf
and useinduction n using (well_founded_induction lt_wf)
. dependent destruction
anddependent induction
requireRequire Import Coq.Program.Equality.
(included in an example on the manual); the error message without this import does not mention them (error message will be improved in v8.7 release).r.(Field)
syntax: same asField r
, but convenient whenField
is a projection function for the (record) type ofr
.