Tactics
Table of Contents
- 1. Summary
- 2. Notes
- 3. Exercises
- 3.1.
silly_ex
- 3.2.
apply_exercise1
- 3.3.
apply_rewrite
- 3.4.
trans_eq_exercise
- 3.5.
injection_ex3
- 3.6.
discriminate_ex3
- 3.7.
eqb_true
- 3.8.
eqb_true_informal
- 3.9.
plus_n_n_injective
- 3.10.
gen_dep_practice
- 3.11.
combine_split
- 3.12.
destruct_eqn_practice
- 3.13.
eqb_sym
- 3.14.
eqb_sym_informal
- 3.15.
eqb_trans
- 3.16.
TODO split_combine
- 3.17.
filter_exercise
- 3.18.
forall_exists_challenge
- 3.1.
- 4. Scores
- 5. Questions
- 6. Metacognition
- 7. Further Knowledge
- 8. TODOs
Homepage | Previous: Polymorphism | Code | Next: TBD
1. Summary
This is a very useful chapter about tactics in Coq. Now it is less tedious, and we can proceed towards doing more complex proofs.
1.1. Terms
symmetry
, transitivity
, unfold
, injection
, discriminate
, generalize dependent
, f_equal
.
2. Notes
We have learned new tactics.
intros
: move hypotheses/variables from goal to contextreflexivity
: finish the proof (when the goal looks likee = e
)apply
: prove goal using a hypothesis, lemma, or constructorapply... in H
: apply a hypothesis, lemma, or constructor to a hypothesis in the context (forward reasoning)apply... with...
: explicitly specify values for variables that cannot be determined by pattern matchingsimpl
: simplify computations in the goalsimpl in H
: simplify computations in a hypothesisrewrite
: use an equality hypothesis (or lemma) to rewrite the goalrewrite ... in H
: use an equality hypothesis (or lemma) to rewrite a hypothesissymmetry
: changes a goal of the formt=u
intou=t
symmetry in H
: changes a hypothesis of the formt=u
intou=t
transitivity y
: prove a goalx=z
by proving two new subgoals,x=y
andy=z
unfold
: replace a defined constant by its right-hand side in the goalunfold... in H
: replace a defined constant by its right-hand side in the goal or a hypothesisdestruct... as...
: case analysis on values of inductively defined typesdestruct... eqn:...
: specify the name of an equation to be added to the context, recording the result of the case analysisinduction... as...
: induction on values of inductively defined typesinjection... as...
: reason by injectivity on equalities between values of inductively defined typesdiscriminate
: reason by disjointness of constructors on equalities between values of inductively defined typesassert (H: e)
(orassert (e) as H
): introduce a “local lemma”e
and call itH
generalize dependent x
: move the variablex
(and anything else that depends on it) from the context back to an explicit hypothesis in the goal formulaf_equal
: change a goal of the formf x = f y
intox = y
3. Exercises
3.1. silly_ex
2 stars, standard, optional
3.2. apply_exercise1
2 stars, standard
3.3. apply_rewrite
1 star, standard, optional
3.4. trans_eq_exercise
3 stars, standard, optional
3.5. injection_ex3
3 stars, standard
3.6. discriminate_ex3
1 star, standard
3.7. eqb_true
2 stars, standard
3.8. eqb_true_informal
2 stars, advanced Skipped.
3.9. plus_n_n_injective
3 stars, standard, especially useful
3.10. gen_dep_practice
3 stars, standard, especially useful
3.11. combine_split
3 stars, standard
3.12. destruct_eqn_practice
2 stars, standard
3.13. eqb_sym
3 stars, standard
3.14. eqb_sym_informal
3 stars, advanced, optional
3.15. eqb_trans
3 stars, standard, optional
3.16. TODO split_combine
3 stars, advanced Stuck here - probably wrong formulation of the identity.
3.17. filter_exercise
3 stars, advanced
3.18. forall_exists_challenge
4 stars, advanced, especially useful
4. Scores
31/36. Skipped one and stuck on split_combine
.
5. Questions
N/A
6. Metacognition
I liked this chapter. It was slightly more challenging because of the expanded move-set but still easy.
A bit more creativity is needed now. I quickly solved them, except that one problem combine_split
.
I was sick recently and so I finished this slightly late.
We are also talking about a new project: formalization of metatheory. I will steer the independent study towards that direction as well.
7. Further Knowledge
(Excerpted from Coq documentation.) Ltac is the tactic language of Coq. Ltac2 is a modernization of Ltac. It aims for a more predictable semantics and more expressivity by including a type system and standard datatypes. It is a member of the ML family of languages. Ltac2 is naturally effectfu, since it changes the state of the proof engine. Proof manipulation lives in a monad. Ltac2 has notations - providing a way to extend the syntax of Ltac2 tactics.