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
1
vote
2 answers

case analysis on evidence of equality type in Coq

I have a query about inductively defined relation eq in Coq. Consider the following definition of eq in Coq: Inductive eq (A : Type) (x : A) : A -> Prop := eq_refl : x = x This is an inductively defined relation just like le (<=). Therefore I…
1
vote
1 answer

Coq: automate repeated rewriting

Example test: forall f (n: nat), f n = n -> f (f n) = n. Proof. intros f n H. repeat rewrite H. reflexivity. Qed. What would be a good way to further automate this? In particular, I would like to not have to mention the name of the hypothesis…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
2 answers

What is the idiomatic way to get `auto` to perform case analysis?

Inductive Foo : nat -> Type := | a : Foo 1. (* ... *) Goal forall m, Foo m -> m = 1. Proof. auto. Fail Qed. Is there a straightforward approach to do this?
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

How to convert "Zneq_bool a b = true" to a witness of "a <> b" in Coq?

I'm trying to prove the following theorem: Theorem Zeq_to_eq: forall (a b : Z), Zneq_bool a b = true -> a <> b. Proof. intros a b. intros neq. rewrite Zeq_bool_neq. Admitted. I get the following error: Error: Tactic failure: setoid rewrite…
Siddharth Bhat
  • 823
  • 5
  • 15
1
vote
1 answer

Coq XML Protocol: a likely PrintAST malfunction

I am using the XML Protocol from Coq 8.6.1. When I tried the PrintAst call, I failed to get an AST, but got an "todo" instead. Is this a malfunction or did I do something wrong? How should I get an AST from a print AST call? Here is my case: I used…
Jian Wang
  • 103
  • 5
1
vote
2 answers

Coq true = false discriminate fails, no primitive equality

I'm trying to prove the following, and I think I have the right approach to solving by enumerating all the cases for b and all the single argument boolean functions f (should be 4 functions over 2 boolean values), proving the point by exhaustively…
rausted
  • 951
  • 5
  • 21
1
vote
0 answers

Right hand side not simplified even with symmetry

Getting started with Coq and "Software Foundation" problems, I run into the following example: Theorem plus_O_n : forall n : nat, 0 + n = n. Proof. intros n. simpl. reflexivity. Qed. Which is proved just fine. When however, I try the right-hand…
rausted
  • 951
  • 5
  • 21
1
vote
1 answer

"Ring" tactic in CoqIde not accepted

I am learning Coq and I need to use, for the first time, the ring tactic. I have tried using it after Require Ring. or Require ArithRing. to simplify the right side of an equation that I have as a goal, but Coq takes it a reference that does not…
Lyuben
  • 13
  • 3
1
vote
1 answer

generalizing expressions under binders

I need to generalize expression under the binder. For example, I have in my goal two expressions: (fun a b => g a b c) and (fun a b => f (g a b c)) And I want to generalize g _ _ c part: One way to do is to rewrite them first into: (fun a b =>…
krokodil
  • 1,326
  • 10
  • 18
1
vote
1 answer

Coq: How to prove max a b <= a+b?

I am unable to prove the simple logic max a b <= a+b using coq's tactics. How should I go about solving it? Below is the code that I worked on till now. s_le_n is proved but not mentioned here for the sake of simplicity. Theorem s_le_n: forall (a b:…
re3el
  • 735
  • 2
  • 12
  • 28
1
vote
1 answer

Establish isomorphism between sigma of a prod and disjoint sum

I defined a Boole inductive type based on the disjoint sum's definition: Inductive Boole := | inlb (a: unit) | inrb (b: unit). Given two types A and B I'm trying to prove the ismorphism between sigT (fun x: Boole => prod ((eq x (inrb tt)) -> A)…
burionk
  • 43
  • 5
1
vote
1 answer

Coq coercions and goal matching

Assume I have the following setup: Inductive exp: Set := | CE: nat -> exp. Inductive adt: exp -> Prop := | CA: forall e, adt e. Coercion nat_to_exp := CE. Ltac my_tactic := match goal with | [ |- adt (CE ?N) ] => apply (CA (CE N)) end. And I try…
Lorenz
  • 1,263
  • 9
  • 20
1
vote
1 answer

Proving a coinduction principle for co-natural numbers

I have to admit that I'm not very good at coinduction. I'm trying to show a bisimulation principle on co-natural numbers, but I'm stuck on a pair of (symmetric) cases. CoInductive conat := | cozero : conat | cosucc : conat -> conat. CoInductive…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

Equality of constructors with dependent types coq

I have the following setup (sorry if it's a bit long for an MCVE) and am trying to prove the last theorem, but I'm getting stuck because it can't unify the types of the morphisms as they rely on theoretically different object types, even though the…
k_g
  • 4,333
  • 2
  • 25
  • 40
1
vote
1 answer

Coq - Proving strict inequality involving bigops in Ssreflect

I am trying to prove the following using the Mathematical Components library: Lemma bigsum_aux (i: 'I_q) (j: 'I_q) (F G : 'I_q -> R): (forall i0, F i0 <= G i0) /\ (exists j0, F j0 < G j0) -> \sum_(i < q) F i < \sum_(i < q) G i. Initially, I was…
VHarisop
  • 2,816
  • 1
  • 14
  • 28