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

Coq: unfold all Definitions

Is there a tactic for unfolding all Definitions (in the goal, optionally also in hypotheses)? Something shorter than unfold def, def0, ... in *.
jaam
  • 900
  • 4
  • 23
4
votes
1 answer

Modus Ponens and Modus Tollens in Coq

I would like to have Ltac tactics for these simple inference rules. In Modus Ponens, if I have H:P->Qand H1:P, Ltac mp H H1 will add Qto the context as H2 : Q. In Modus Tollens, if I have H:P->Qand H1:~Q, then Ltac mt H H1 will add H2:~Pto the…
mlg556
  • 419
  • 3
  • 13
4
votes
2 answers

Disjunctive Syllogism tactic in Coq?

I am learning propositional logic and the rules of inference. The Disjunctive Syllogism rule states that if we have in our premises (P or Q), and also (not P); then we can reach Q. I can not for the life of me figure out how to do this in Coq.…
mlg556
  • 419
  • 3
  • 13
4
votes
1 answer

Coq: Rewriting with 'forall' in hypothesis or goal

I have proved 'correctness' of the reverse function on polymorphic Lists in Coq. The following proof works just fine, but I have a few questions about how the rewrite tactic works. Here's the code: Require Export Coq.Lists.List. Import…
Akay
  • 225
  • 2
  • 8
4
votes
1 answer

Apply a function to both sides of equality in a Coq hypothesis

The question I have is very similar to the one presented in the link below, but on a hypothesis instead of a goal. Apply a function to both sides of an equality in Coq? Say I have the following definition : Definition make_couple (a:nat) (b:nat) :=…
csix
  • 60
  • 6
4
votes
1 answer

Coq: working with inequalities (<>)

I'm trying to understand the logic about working with inequalities in Coq. When <> is present in the goal, doing intros contra. changes the goal to False and moves the goal to an hypothesis but with <> switched to =. I think I understand how it is…
Waiting for Dev...
  • 12,629
  • 5
  • 47
  • 57
4
votes
1 answer

Coq contradiction in hypotheses

In Coq I have two hypotheses H and H0, that contradict each other. Problem is, they only contradict each other for some specializations and at this moment of the proof the context is not that specialized. At this moment my proof context looks like…
Alexander Boll
  • 228
  • 1
  • 7
4
votes
2 answers

Check for evars in a tactic that returns a value

I'm trying to write a tactic that returns a value, and in the course of doing so it needs to check if something is an evar. Unfortunately, I can't use is_evar because then the tactic isn't deemed to return a value (but rather another tactic). An…
Rand00
  • 376
  • 1
  • 8
4
votes
1 answer

Defining different equality types as inductive types in Coq

I am trying to define in Coq different types of equalities. During an university course my professor gave us the rules of four different types, as follows (I provide just the links to the rules): Gentzen : https://ibb.co/imQOCF Leibniz :…
madipi
  • 355
  • 2
  • 11
4
votes
1 answer

How to repeat proof tactics in case in Coq?

I would like to extend the exercise 6.10 in Coq'Art by adding a theorem that forall months which are not January, is_January will equal false. My definition of months looks like this: Inductive month : Set := | January : month | February :…
Mike Harris
  • 869
  • 9
  • 21
4
votes
2 answers

How do you selectively simplify arguments to each time a function is called, without evaluating the function itself?

I'm using Coq 8.5pl1. To make a contrived but illustrative example, (* fix so simpl will automatically unfold. *) Definition double := fix f n := 2*n. Theorem contrived n : double (2 + n) = 2 + double (1 + n). Now, I only want to simplify the…
scubed
  • 307
  • 3
  • 10
4
votes
2 answers

Coq can't discriminate between constructors for dependently typed inductive proposition

I created this example type to demonstrate the problem I'm having: Inductive foo : nat -> Prop := | foo_1 : forall n, foo n | foo_2 : forall n, foo n. Now clearly foo_1 0 <> foo_2 0, but I'm unable to prove this: Lemma bar : foo_1 0 <> foo_2…
igorbark
  • 95
  • 4
4
votes
2 answers

What's the difference between logical (Leibniz) equality and local definition in Coq?

I am having trouble understanding the difference between an equality and a local definition. For example, when reading the documentation about the set tactic: remember term as ident This behaves as set ( ident := term ) in * and using a logical…
thor
  • 21,418
  • 31
  • 87
  • 173
4
votes
2 answers

coq: elimination of forall quantifier

I want to prove the following theorem: Theorem Frobenius (A: Set) (q: Prop) (p: A -> Prop) : (q \/ forall x : A, p x) -> (forall x : A, q \/ p x). I already got the following piece of the proof: Proof. intro. intro. destruct…
bliblablub
  • 43
  • 5
4
votes
2 answers

Coq proof tactics

I am a beginner at Coq proof system (about 4 days). I've tried hard, but I am not able to prove the following. forall a b c : nat, S (S (a + b)) = S (S (a + c)) -> b = c. As far as I know, we need to prove the bijectivity of +, so that we can…
Codi
  • 511
  • 3
  • 19
1 2
3
25 26