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
2
votes
3 answers

How to write intermediate proof statements inside Coq - similar to how in Isar one has `have Statement using Lemma1, Lemma2 by auto` but in Coq?

I wanted to write intermediate lemmas inside Coq proof scripts, e.g., inside SCRIPT in Proof. SCRIPT Qed. itself - similar to how one would do in Isar. How does one do this in Coq? e.g.: have Lemma using Lemma1, Lemma2 by auto. I am aware of the…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
2
votes
1 answer

How to try a tactic in Ltac, but continue if it fails

I have a proof which concludes in two cases which look like this: + rewrite H. apply lemma1. + apply lemma1. While this is relatively simple I would like to combine this into a single tactic. What I want to do in English is, "try to rewrite and if…
sdpoll
  • 426
  • 2
  • 12
2
votes
1 answer

Modulo simplification in coq

I am a beginner at Coq and I'm stuck at a problem in Coq, I am not able to simplify this further. It would be great if anyone had any tips on how to break the problem down into smaller steps. The lemma is this: forall (n : N) (n0 : N), ((1 + 2 * n…
2
votes
1 answer

Coq: eliminating `forall`?

I am struggling to prove the following theorem (non-empty domain is assumed): Theorem t (A: Set) (P: A -> Prop): (forall a: A, P a) -> (exists a: A, P a). Proof. intros H. Noramlly, having forall a: A, P a I would deduce P c, where c is a…
Zazaeil
  • 3,900
  • 2
  • 14
  • 31
2
votes
1 answer

In Coq, is there a way to see the tactics applied by tauto?

Is there a way to see the tactics applied by tauto? I.e., run tauto and get a list of tactics to apply (not including tauto)?
Andrew W
  • 4,530
  • 1
  • 16
  • 16
2
votes
4 answers

Is it possible to prove `forall n: nat, le n 0 -> n = 0.` in Coq without using inversion?

In the official coq tutorial they define the following inductive definition of less than or equal to: Inductive le (n : nat) : nat -> Prop := | le_n : le n n | le_S : forall m : nat, le n m -> le n (S m). My understanding of…
William Oliver
  • 1,412
  • 4
  • 24
  • 35
2
votes
3 answers

How to pattern match exist to transform proofs

I'm messing around with coq and I'm trying to create a function that can be used to lookup something in a list and return an associated proof with it that the specified element is in the list. In my case I have a list of tuples and I want to lookup…
user2882307
2
votes
1 answer

If two constructor expressions of an inductive type are equal in Coq, can I do rewriting based on their corresponding arguments?

I do have a 4-tuple inductive type as follows: Inductive my_tuple := | abcd : byte -> nat -> byte -> nat -> my_tuple. and in my context I do have the following: H : abcd b1 n1 b2 n2 = abcd b1' n1' b2' n2' Given the fact that all constructors for…
2
votes
2 answers

Ltac unification variable containing locally-bound variables

The Ltac chapter of CPDT, shows a "faulty" tactic: Theorem t1' : forall x : nat, x = x. match goal with | [ |- forall x, ?P ] => trivial end. The book then explains The problem is that unification variables may not contain locally bound…
abeln
  • 3,749
  • 2
  • 22
  • 31
2
votes
1 answer

How to explicitly use an induction principle in coq?

I'm trying to prove symmetry of propositional identity with the induction principal explicitly in Coq, but can't do it with the induction principle like I can in agda. I don't know how to locally declare a variable in Coq, nor do I know how to…
user5775230
2
votes
1 answer

How to use Coq arithmetic solver tactics with SSReflect arithmetic statements

Coq has some convenient tactics for automatically proving arithmetic lemmas, for instance lia: From Coq Require Import ssreflect ssrfun ssrbool. From mathcomp Require Import ssrnat. Set Implicit Arguments. Unset Strict Implicit. Unset Printing…
LogicChains
  • 4,332
  • 2
  • 18
  • 27
2
votes
1 answer

How to prove the same subgoals

I have two equal subgoals like this: prove_me (x::xs) = true prove_me (x::xs) = true Proofs will be equals. How I can solve the second goal using the first one?
he11boy
  • 71
  • 3
2
votes
2 answers

In Coq, are there tactics for working with Rabs, Rineq?

I am new to Coq, and my primary interest is in using it to do simple real analysis problems. For a first exercise, I managed to bash through a proof that x^2+2x tends to 0 as x tends to 0. See code below. This seems pretty clunky, and I would be…
anon
  • 235
  • 2
  • 9
2
votes
1 answer

Coq: Proving relation between < and ≤

I am learning Coq right now and in a larger proof I have become stumped by the following sub-proof: Theorem sub : ∀ n m : nat, n ≤ m → n ≠ m → n < m. Or, once unfolded: Theorem sub : ∀ n m : nat, n ≤ m → n ≠ m → S n ≤ m. Here, "n ≤ m" is…
Rakeeb Hossain
  • 353
  • 1
  • 11
2
votes
1 answer

Match context pattern inside a tactic/tactic notation

I find a pattern inside my goal through a tactic. Why does this fail: Tactic Notation "my_context_match" uconstr(g) := match goal with | |- context[g] => idtac end. my_context_match _. While this…
user2506946
  • 131
  • 9