Questions tagged [coq-tactic]

Tactics are programs written in Ltac, the untyped language used in the Coq proof assistant to transform goals and terms. This tag should be used on questions related to the issues in using Coq tactics to derive proofs using the Coq proof assistant.

Tactics are programs written in Ltac, the untyped language used in the Coq proof assistant to transform goals and terms. In general, the aim of using tactics is to construct a proof or proof object for the theorem in question. Initially, the proof object contains a hole corresponding to the goal of the theorem in question. As the proof proceeds, tactics transform the current goal/sub-goal and hypotheses in the local proof context using established theorems in the global context as well as hypotheses in the local context. Some tactics can introduce new sub-goals corresponding to new holes in the proof object. For example, if the goal is a conjunction P /\ Q, can be decomposed into two sub-goals P and Q using the split tactic. Certain tactics can also reduce the number of sub-goals (or holes in the proof object). The theorem is proved when there is no more sub-goals to prove (i.e. no more holes to fill in the proof object).

Strictly speaking, tactics are not necessary to prove theorems in Coq. It is possible to construct a proof object directly. However, tactics provide an interactive way of constructing a proof, which are closer to the manner proofs are developed manually.

For a comprehensive documentation of tactics, see the Coq reference manual: https://coq.inria.fr/refman/tactic-index.html

383 questions
3
votes
1 answer

Automatically choose an assumption from local context

I have a proof script with a section that looks like this: - destruct (IHx1 _ _ H3). subst. destruct (IHx2 _ _ H7). congruence. - destruct (IHx1 _ _ H6). congruence. - destruct (IHx1 _ _ H3). subst. destruct (IHx2 _ _ H7). congruence. -…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
3
votes
1 answer

Is is possible to implement a Coq tactic that inspects a HintDb? If so, how?

For example, I would like a tactic that would iterate over all the resolve hints in a given HintDb and for each resolve hint h, it would do a pose h. . Is this possible? If so, how?
Bruno
  • 854
  • 7
  • 21
3
votes
2 answers

How can I implement a coq tactic that iterates over the hypotheses?

As minimal example for my general question, suppose we have the following: Parameter C: Prop. Definition blah := C. I would like to implement a tactic that automatically unfolds blah in all hypotheses of the goal. I tried this: Ltac my_auto_unfold…
Bruno
  • 854
  • 7
  • 21
3
votes
1 answer

How to leverage auto's searching and hint databases in custom tactics?

In my coq development I am learning how to create new tactics tailored to my problem domain, a la Prof. Adam Chlipala. On that page he describes how to create powerful custom tactics by e.g. combining repeat with match. Now, I already have a…
phs
  • 10,687
  • 4
  • 58
  • 84
3
votes
1 answer

Usage of "red in |- *": What does bar hyphen star mean?

In a lot of Coq code, like in the definition of sets in the standard library, I've seen this sort of notation: red in |- *. What does the |-* (bar-hyphen-star) mean? My searching hasn't turned up any results, but it's hard to search for…
Langston
  • 1,083
  • 10
  • 26
3
votes
1 answer

multiple successes in Coq branching and backtracking?

I am having trouble understanding the concept of multiple successes in Coq's (8.5p1, ch9.2) branching and backtracking behavior. For example, from the documentation: Backtracking branching We can branch with the following structure: expr1 +…
thor
  • 21,418
  • 31
  • 87
  • 173
3
votes
3 answers

Merge duplicate cases in match Coq

I have come by this problem many times: I have a proof state in Coq that includes matches on both sides of an equality that are the same. Is there a standard way to rewrite multiple matches into one? Eg. match expression_evaling_to_Z with …
k_g
  • 4,333
  • 2
  • 25
  • 40
3
votes
1 answer

How to automatically prove simple equality of real numbers in Coq?

What I am looking for is an auto-like tactic that can prove simple equalities like: 1/2 = 2/4 So far, what I've tried manually is to use ring_simplify and field_simplify to prove equalities. Even this doesn't work out well (Coq 8.5b3). The example…
thor
  • 21,418
  • 31
  • 87
  • 173
3
votes
1 answer

info_auto tactic does not print traces anymore in Coq8.5?

I used to use info_auto to display the steps actually performed under the hood by an auto tactic. However, this no longer seems to work with Coq 8.5 (beta3). The following example used to work for Coq 8.4: Example auto_example_5: 2 = 2. Proof. …
thor
  • 21,418
  • 31
  • 87
  • 173
3
votes
1 answer

rewrite works for = but not for <-> (iff) in Coq

I have the following during a proof, in which I need to replace normal_form step t with value t as there is a proven theorem that there are equivalent. H1 : t1 ==>* t1' /\ normal_form step t1' t2' : tm H2 : t2 ==>* t2' /\ normal_form step…
thor
  • 21,418
  • 31
  • 87
  • 173
3
votes
2 answers

How to prove (n = n) = (m = m) in Coq?

I am confused about the evidence and Prop etc. in Coq. How do we prove that (n = n) = (m = m)? My intention is to show this is somehow True=True. But this is even correct formulation? What I tried so far is: Theorem test: forall m n:nat, (n = n) =…
thor
  • 21,418
  • 31
  • 87
  • 173
3
votes
3 answers

How to save the current goal / subgoal as an `assert` lemma

During a proof, I come to a situation where the current goal/subgoal turned out to be useful in a later stage of the same theorem. Is there a tactic to "save" the current goal as a lemma as if the current goal is asserted? Of course, I can…
thor
  • 21,418
  • 31
  • 87
  • 173
3
votes
1 answer

Can destruct used in implication in Coq?

destruct can be used to split and, or in Coq. But it seems can also be used in implication? For example, I want to prove ~~(~~P -> P) Lemma test P : ~~(~~P -> P). Proof. unfold not. intro pffpf. apply pffpf. intro pff. destruct pff. intro p. apply…
1ang
  • 321
  • 2
  • 3
  • 11
2
votes
1 answer

How to rearrange newly defined associative terms in Coq?

I wonder what is the most elegant way of rearranging associative terms in Coq. I think it is a well-defined problem for some existing operators, such as plus. I have defined new associative operater and operands with corresponding types. In short,…
2
votes
1 answer

Why is my local coq no acting the same as standard coq e.g. as JsCoq?

I was going through the trivial example in this question How can I rewrite "+ 1" (plus one) to "S" (succ) in Coq? but the proof does not work in my local computer despite it working on jscoq. This is where my proof gets stuck: Lemma s_is_plus_one: …
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323