Tactics

Table of Contents


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 context
  • reflexivity: finish the proof (when the goal looks like e = e)
  • apply: prove goal using a hypothesis, lemma, or constructor
  • apply... 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 matching
  • simpl: simplify computations in the goal
  • simpl in H: simplify computations in a hypothesis
  • rewrite: use an equality hypothesis (or lemma) to rewrite the goal
  • rewrite ... in H: use an equality hypothesis (or lemma) to rewrite a hypothesis
  • symmetry: changes a goal of the form t=u into u=t
  • symmetry in H: changes a hypothesis of the form t=u into u=t
  • transitivity y: prove a goal x=z by proving two new subgoals, x=y and y=z
  • unfold: replace a defined constant by its right-hand side in the goal
  • unfold... in H: replace a defined constant by its right-hand side in the goal or a hypothesis
  • destruct... as...: case analysis on values of inductively defined types
  • destruct... eqn:...: specify the name of an equation to be added to the context, recording the result of the case analysis
  • induction... as...: induction on values of inductively defined types
  • injection... as...: reason by injectivity on equalities between values of inductively defined types
  • discriminate: reason by disjointness of constructors on equalities between values of inductively defined types
  • assert (H: e) (or assert (e) as H): introduce a “local lemma” e and call it H
  • generalize dependent x: move the variable x (and anything else that depends on it) from the context back to an explicit hypothesis in the goal formula
  • f_equal: change a goal of the form f x = f y into x = 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.

8. TODOs

8.1. Fill in metacognition and further knowledge.

Author: selffins

Created: 2025-04-12 Sat 22:32