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

How can I build a list of bytes from its specification in Coq

I'm trying to build a list of bytes according to the specification I do have in my context (The specification is defined based on the conjunction of nth_error functions that determine a byte value at an index (or byte values in a range of indices).…
0
votes
1 answer

Can I use destruct here given the constraint I have for index range of a list?

I’m trying to prove that for a list of bytes a, all bytes are x01 from index 2 to (n-m-2), where n is the length of a: (forall (i : nat), ((i >= 2) /\ (i < ((n - m) - 1))) -> ((nth_error a i) = (Some x01))) and I do have this in the context: H :…
0
votes
2 answers

Reorder display of hypothesis in Coq?

Is there a tactic to reorder the display of hypothesis within a Coq proof. Very often while using induction (the hypothesis are very long) and I would like to print all definitions at the top and all other equations together.
Anon
  • 381
  • 1
  • 2
  • 13
0
votes
1 answer

"at next level" in Coq?

What does the 'at next level' bit mean in the following notation (given that the level is already specified): Reserved Notation "t1 ->> t2" (left associativity, at level 69, t2 at next level). ... where "t1 ->> t2" := (xform t1 t2). where xform is…
Anon
  • 381
  • 1
  • 2
  • 13
0
votes
2 answers

Does using the unfold tactic followed by fold in Coq do anything?

Will unfold def. fold def. ever achieve anything in a Coq proof? Put differently: will there ever be a difference between these two sequences of applications of tactics?: unfold def. fold def. cbn. cbn.
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
0
votes
1 answer

Apply a lemma to a conjunction branch without splitting in coq

I have a conjunction, let's abstract it as: A /\ B and I have a Lemma proven that C -> A and I wish to get as a result the goal C /\ B. Is this possible? If yes, I'd be interested in how to do it. If I use split and then apply the lemma to the first…
Marius Melzer
  • 863
  • 1
  • 7
  • 10
0
votes
1 answer

How can I rename an existentially quantified variable in a hypothesis?

Is there an easy way to rename an existential variable in a hypothesis? Sometimes the variable names are confusing, because the same names are reused in unrelated hypotheses. For example, I want to change H1 : exists p : nat, n0 = p * 2 to H1 :…
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
0
votes
1 answer

How in Coq to use mod arithmetic (specifically Zplus_mod theorem) for natural numbers?

I want to apply the library theorem: Theorem Zplus_mod: forall a b n, (a + b) mod n = (a mod n + b mod n) mod n. where a b n are expected to have the type Z. I have a subexpression (a + b) mod 3 in my goal, with a b : nat. rewrite Zplus_mod gives…
mercury0114
  • 1,341
  • 2
  • 15
  • 29
0
votes
1 answer

Debugging specialize and/or apply errors in Coq

I'm trying to figure out the source of the following error with the apply (list2map_not_in_default [(k, v)] i) in H2. command. Here is the list2map_not_in_default type: list2map_not_in_default : forall (al : list (key * V)) (i : key), …
user5775230
0
votes
2 answers

Coq auto tacitc fails

I have the following Coq program that tries to prove n <= 2^n with auto: (***********) (* imports *) (***********) Require Import Nat. (************************) (* exponential function *) (************************) Definition f (a : nat) : nat :=…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
0
votes
1 answer

Variant of the induction tactic that doesn't require using `remember` on subterms

Let's say I have two relations R1 and R2. If I need to solve a problem by induction over the term R1 A (R2 B C), I need to first do remember R2 B C, otherwise I lose the information that the second argument to R1 was equal to R2 B C. Is there a…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
0
votes
1 answer

(A -> B) /\ (B -> C) -> (A -> C) in Coq?

I am learning Coq via the book software foundations, and have trouble proving the following lemma (which I require to prove other theorems.) Lemma if_trans : forall (P Q R: Prop), (P -> Q) /\ (Q -> R) -> (P ->R). Proof. intros P Q R [E1…
Anon
  • 381
  • 1
  • 2
  • 13
0
votes
1 answer

Coq use refine with bi-implication

I'm not sure how to word my question, because I'm new to coq. I want to use refine with a theorem that includes bi-implication. Example code: Parameters A B C : Prop. Theorem t1: A -> B -> C. Admitted. Theorem t2: A -> B <->…
mdatsev
  • 3,054
  • 13
  • 28
0
votes
3 answers

How to prove equality from equality of Some

I want to prove equality of two nat numbers in Coq: a, b : nat Heq : Some a = Some b ============================ a = b
he11boy
  • 71
  • 3
0
votes
1 answer

Why does removing assumptions change the behaviour of the induction tactic?

I am trying to show that the various definitions of the reflexive-transitive closure are equivalent. Here is code that works: Require Import Coq.Relations.Relation_Definitions. Require Import Coq.Relations.Relation_Operators. Hint Constructors…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46