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

Coq: How to produce a strong polymorphic dependent type hypothesis

I have been having some problems with dependent induction because a "weak hypothesis". For example : I have a dependent complete foldable list : Inductive list (A : Type) (f : A -> A -> A) : A -> Type := |Acons : forall {x x'' : A} (y' : A) (cons'…
Tiago Campos
  • 503
  • 3
  • 14
0
votes
0 answers

Basics.vo contains library Basics and not library Metalib.Basics

I am getting the error "Basics.vo contains library Basics and not library Metalib.Basics" in CoqIDE 4.5. I am following Software Foundations and importing Basics as 'Require Export Basics.'. Also I compiled the Basics using the same CoqIDE. In the…
Baber
  • 301
  • 2
  • 6
  • 17
0
votes
0 answers

Applying a tactic after epose or eset

I want to make a tactic like let x := fresh in epose (x := _); forward_call x. forward_call is tactic to process function call in VST. I find if I do epose _; forward_call x (if x is the name by epose), it goes into finite loop, too. But it works…
Qinshi Wang
  • 129
  • 4
0
votes
2 answers

Coq fails an apply tactic

I am trying to prove the following simple theorem over natural numbers: ((i + j) = (i + k)) -> (j = k) Here is what I have in Coq: Theorem cancel : forall (i j k : nat), ((add i j) = (add i k)) -> (j = k). Proof. intros i j k. induction…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
0
votes
1 answer

Coq simple implies proof

I am trying to prove the following trivial cancellation theorem for natural numbers: forall i, j, k in nat . ((i+j) = (i+k)) -> (j = k) Here is what I wrote in Coq: Theorem cancel : forall (i j k : nat), ((add i j) = (add i k)) -> (j =…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
0
votes
1 answer

How to destruct a theorem into all three disjuncts in one step?

I have already proved the following lemma: Lemma ord_semiconnex_bool : forall (alpha beta : ord), ord_ltb alpha beta = true \/ ord_ltb beta alpha = true \/ ord_eqb alpha beta = true. I would like to do case analysis on it for another theorem I'm…
0
votes
1 answer

how to create conditionals in a Fixpoint definition Coq

I am working through the book "Software Foundations", and am on the last problem in Chapter two. The problem asks to convert a natural number into a binary number, where a binary number is defined in the following ways: - [is] zero, - [is] twice…
Roquentin
  • 177
  • 2
  • 12
0
votes
1 answer

Reduction in coq when the simpl or cbn tactics are not effective

I am trying to prove this: Fixpoint max(a: nat)(b:nat): nat := if a <=? b then b else a. Example ex: forall n:nat, n = max n n. Proof. intros. (...) The simpl and cbn tactics do not produce anything. If I call cbv [max], then I get a redex and I…
0
votes
1 answer

how to rewrite something true to True

given a goal involving ... <-> Forall P [] I want to rewrite Forall P [] to True and then rewrite True /\ Forall P ys to Forall P ys (1) there is a theorem Forall_nil saying Forall P [] but how do I use that to rewrite Forall P [] to True (2)…
0
votes
0 answers

Substitute argument of `fix` in proof

This question is probably trivial, but I'm stuck on it since yesterday and I couldn't find the relevant keyword to search for. Consider the following: Fixpoint mfp (t: nat*nat) := fst t. Lemma ml: forall (t: nat*nat), mfp t = fst t. Proof. …
Bromind
  • 1,065
  • 8
  • 23
0
votes
0 answers

Rewrite right to left in Ltac or Tactic Notation

How does one use fancier versions of the rewrite tactic when defining tactics or tactic notations? Both of the following produce a Error: Syntax error: '.' expected after [vernac:command] (in [vernac_aux]). Ltac rewrite_right n H := rewrite <- n…
Ifaz Kabir
  • 134
  • 8
0
votes
1 answer

Ltac: Matching goal with type that depends on name of previous goal

I'm trying to write Ltac code that looks like this: match goal with | [ e : expr, H : (is_v_of_expr e = true) |- _ ] => idtac end. (* The reference e was not found in the current environment *) The problem is, trying to match a case where…
jmite
  • 8,171
  • 6
  • 40
  • 81
0
votes
1 answer

Using backtracking to find value for existential in Coq

I'm in a situation where I have a goal of the following form: exists x : T1, f x = y. where y : T2 and f : T1 -> T2. The trick is that I've defined T1 and T2 in such a way that their constructors correspond, so for a human, it's easy to see what…
jmite
  • 8,171
  • 6
  • 40
  • 81
0
votes
1 answer

erewrite that asks for hypothesis first?

I want a variant of erewrite which asks for the hypothesis first, and then proceeds to the rewritten goal, rather than the other way round. Here is a small example: Variable P : Prop. Variable SomeProp: Prop -> Prop. Lemma rewriter: forall (R:…
Siddharth Bhat
  • 823
  • 5
  • 15
0
votes
1 answer

reasoning about typeclass instance that has been picked up in a theorem?

Class Action (Actor: Type) (Acted: Type) := { act : Actor -> Acted -> Acted; someProof: forall (a: Actor), a = a; }. Instance natListAction: Action nat (list nat) := { act (n: nat) (l: list nat) := cons n l; }. Proof. …
Siddharth Bhat
  • 823
  • 5
  • 15