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

Duplicate subgoals in Coq

Is there some Coq tactic to prevent the generation of several identical subgoals? If not, is it possible to write some tactic for eliminating the duplicate subgoals just after its generation? In Isabelle you can do it with: apply (tactic {*…
jiplucap
  • 155
  • 7
1
vote
1 answer

Coq: How to rewrite inside a lambda?

Basically, I want to prove the following lemma, but I'm having trouble since I can't seem to directly rewrite inside of the lambdas. However I feel like this should be possible, because if I were "inside" the lambda, I could easily prove it for any…
Reed Oei
  • 1,427
  • 2
  • 13
  • 19
1
vote
1 answer

How can I use type arguments in an ltac?

I'm trying to write the following function: Ltac restore_dims := repeat match goal with | [ |- context[@Mmult ?m ?n ?o ?A ?B]] => let Matrix m' n' := type of A in let Matrix n'' o' := type of B in …
Rand00
  • 376
  • 1
  • 8
1
vote
1 answer

Field tactic with partial inverse function

Coq defines the multiplicative inverse function 1/x as a total function R -> R, both in Rdefinitions.v and in Field_theory.v. The value 1/0 is left undefined, all calculation axioms ignore it. However this is a problem in constructive mathematics,…
V. Semeria
  • 3,128
  • 1
  • 10
  • 25
1
vote
1 answer

Transfering proof from Z to N in Coq

Is there a way in Coq in to prove a statement for integer numbers and the transfer statement in a semi-automatic way to naturals? For a concret example, take the following lemma: Lemma cancellation: forall a b c: nat, a > 0 -> a * b = a * c -> b =…
Andrea
  • 20,253
  • 23
  • 114
  • 183
1
vote
1 answer

Using induction starting from 1 in Coq

I am trying to use induction starting from 1 in a Coq proof. From this question I got a proof of the induction principle I need: Section induction_at_1. Variable P : nat -> Prop. Hypothesis p1 : P 1. Hypothesis pS : forall n, P n -> P (S n). …
Andrea
  • 20,253
  • 23
  • 114
  • 183
1
vote
1 answer

Are there any tactics to work with preconditions with "and"?

My goal is like below. Are there any tactics to solve these trivial goals? Goal forall A (x : A) P Q, (forall y, P y /\ Q y) -> Q x. Proof. intros. intuition. auto. Abort. (* a more complex version *) Goal forall A (x : A) P Q R, (forall y,…
Qinshi Wang
  • 129
  • 4
1
vote
1 answer

Are Coq tacticals right associative or left associative?

I was going through software foundations and got the example: repeat (try (left; reflexivity); right). and was confused what this meant. For example do we get: try [ (left; reflexivity); right ] or [try (left; reflexivity);] right second or…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
1
vote
1 answer

Ltac position argument for instantiate

The tactic instantiate can take and ident or a num as: instantiate (ident:= term) instantiate (num := term) Now I want to use the second one inside a tactic definition. For example: Ltac my_instantiate n x:= …
user2506946
  • 131
  • 9
1
vote
2 answers

Preserving structure with inductions on 2 variables

I've been learning about Coq's tactics and familiarizing myself with the system by reproving basic facts about natural numbers. I've been trying to avoid using the theorems that are already proven in the library, and reproving things like the…
Tony Peterson
  • 20,522
  • 15
  • 48
  • 66
1
vote
1 answer

Remove All Double Negations in Coq

I would like to systematically remove all double negations which can appear in my hypotheses and goals. I know that ~~A -> Ais not a part of intuitionist logic, but the course I am taking is classical, so I don't mind. I am aware that the mentioned…
mlg556
  • 419
  • 3
  • 13
1
vote
2 answers

Splitting a premise with conjunction conclusion in Coq

I often have to do "induction loading" to prove goals in Coq, where I prove multiple things simultaneously by induction. The problem is, I often end up with Inductive Hypotheses of the following form: forall a1 ... an, Premise1 -> Premise2 -> ...…
jmite
  • 8,171
  • 6
  • 40
  • 81
1
vote
2 answers

Conditional Proof Tactic in Coq

I believe the title is pretty self explanatory : https://en.wikipedia.org/wiki/Conditional_proof I would like to have a tactic where I assume a proposition and proceed to find another one, if succeeded, then I have found that the first proposition…
mlg556
  • 419
  • 3
  • 13
1
vote
0 answers

Coq: Port a Ltac tactic using CPS style to an ML tactic (OCaml plugin)

I'm trying to port a Coq tactic (currently written in Ltac) to OCaml, in order to be able to extend that tactic more easily (and avoid the hacks I needed to emulate in Ltac some data structures that are otherwise quite standard in OCaml). I am…
ErikMD
  • 13,377
  • 3
  • 35
  • 71
1
vote
1 answer

Why can IHn' (n' = n' + 0) from induction be used to prove n = n + 0 in Coq?

In Software Foundations's Logical Foundations, they use the idea of induction to prove things. From stepping through the following proof, it is difficult to see why you can rewrite what you're trying to prove with your original hypothesis. Why can…