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
6
votes
1 answer

Shorter notation for matching hypotheses in Coq?

I find myself often wanting to refer to hypotheses by their type rather than by their name; especially in proofs with inversions on semantic rules, i.e., rules with several cases each of which may have multiple antecedents. I know how to do this…
tbrk
  • 1,290
  • 1
  • 13
  • 20
6
votes
2 answers

Coq: destruct (co)inductive hypothesis without losing information

Consider the following development: Require Import Relation RelationClasses. Set Implicit Arguments. CoInductive stream (A : Type) : Type := | scons : A -> stream A -> stream A. CoInductive stream_le (A : Type) {eqA R : relation A} …
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
6
votes
2 answers

Raising the failure level of a coq tactic

When implementing a complex tactic in Ltac, there are some Ltac commands or tactic invocation that I expect to fail and where that is expected (e.g. to terminate a repeat, or to cause backtracking). These failures are usually raised at failure level…
Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
6
votes
2 answers

Decomposing equality of constructors coq

Often in Coq I find myself doing the following: I have the proof goal, for example: some_constructor a c d = some_constructor b c d And I really only need to prove a = b because everything else is identical anyway, so I do: assert (a = b). Then…
k_g
  • 4,333
  • 2
  • 25
  • 40
6
votes
3 answers

How to add to both sides of an equality in Coq

This seems like a really simple question, but I wasn't able to find anything useful. I have the statement n - x = n and would like to prove (n - x) + x = n + x I haven't been able to find what theorem allows for this.
k_g
  • 4,333
  • 2
  • 25
  • 40
5
votes
2 answers

Coq simpl / unfold only once. (Replace part of goal with the result of one iteration of a function.)

I am an instructor at university for a class titled Type Systems of Languages and the professor used the following example for inductive proofs in Type Theory on the board last lecture: Suppose, that there are natural numbers defined inductively…
Isti115
  • 2,418
  • 3
  • 29
  • 35
5
votes
1 answer

In the coq tactics language, what is the difference between intro and intros

In the Coq tactics language, what is the difference between intro and intros?
nixon
  • 1,952
  • 5
  • 21
  • 41
5
votes
1 answer

How to look at multiple goals at the same time?

I am considering writing tactics which will look at multiple goals and make decision based on that. However, when I use match goal with and stare at a goal, how do I say "please find another goal that looks like this"? Or rather, a more general…
Jason Hu
  • 6,239
  • 1
  • 20
  • 41
5
votes
1 answer

What does the Coq command Require Import Ltac do?

When I am looking at the QuickChick project, I encountered the sentence Require Import Ltac. I don't know what this does and where the Ltac module is. I found a file plugins/ltac/Ltac.v, but this couldn't be the one since this file is empty (by the…
Jian Wang
  • 103
  • 5
5
votes
1 answer

`decide equality` for Mutually Recursive Types in Coq?

Is there any way to use the decide equality tactic with mutually recursive types in Coq? For example, if I've got something like this: Inductive LTree : Set := | LNil | LNode (x: LTree) (y: RTree) with RTree : Set := | RNil | RNode (x:…
5
votes
1 answer

Simplifying Subformulas in Coq

I'm trying to solve an equation of the form A * B * C * D * E = F where * some complicated left associative operation. At the moment, everything is opaque (including * and A through F), and can be made transparent via autounfold with M_db. The…
Rand00
  • 376
  • 1
  • 8
5
votes
3 answers

rewrite single occurence in ltac

How can I invoke rewrite in ltac to only rewrite one occurrence? I think coq's documentation mentions something about rewrite at but I haven't been able to actually use it in practice and there are no examples. This is an example of what I am trying…
Mei Zhang
  • 1,434
  • 13
  • 29
5
votes
1 answer

How to apply a function once during simplification in Coq?

From what I understand, function calls in Coq are opaque. Sometimes, I need to use unfold to apply it and then fold to turn the function definition/body back to its name. This is often tedious. My question is, is there an easier way to let apply a…
thor
  • 21,418
  • 31
  • 87
  • 173
5
votes
3 answers

How to introduce a new variable in Coq?

I was wondering if there is a way to introduce an entirely new variable during the proof of a theorem in Coq? For a complete example, consider the following property from here about the evenness of the length of a list. Inductive ev_list {X:Type}:…
thor
  • 21,418
  • 31
  • 87
  • 173
4
votes
1 answer

Coq: rewriting under if-then-else

I sometimes need to apply a simplification in a branch of an if-then-else without destructing the discriminee. From Coq Require Import Setoid. Lemma true_and : forall P, True /\ P <-> P. Proof. firstorder. Qed. Goal (forall (b:bool) P Q, if b…
pjm
  • 269
  • 1
  • 8
1
2
3
25 26