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 to split equality of two lists?

I have the following goal and context: A : Type eqb : A -> A -> bool H : forall a1 a2 : A, eqb a1 a2 = true <-> a1 = a2 x : A l1' : list A IHl1' : forall l2 : list A, eqb_list eqb l1' l2 = true <-> l1' = l2 y : A l2' : list A IHl2'…
Felipe Balbi
  • 147
  • 7
0
votes
2 answers

Can't figure out why re-write does not work

I'm learning coq and can't figure out why a rewrite doesn't work. My code looks like this: Inductive nat : Type := | zero | succ (n : nat) . Fixpoint add (a b : nat) : nat := match b with | zero => a | succ b' => add (succ a) b' …
azani
  • 486
  • 3
  • 14
0
votes
1 answer

Software Foundations Volume 1: Tactics: injection_ex3

Could some explain how to complete this proof? (please don't give the actual answer, just some guidance :) The exercise is from SF volume1, as stated in the title and it goes like this: (** **** Exercise: 3 stars, standard (injection_ex3) *) Example…
Felipe Balbi
  • 147
  • 7
0
votes
0 answers

VSCoq ProofView not printing

When using Visual Studio Code with enabled VSCoq and coq extensions, stepping through the proof works well but the ProofView window shows blank (no content). What could be the issue and solutions to fix this?
Fusen
  • 311
  • 2
  • 3
  • 10
0
votes
1 answer

An assumption in the goal is completely the same with a function I defined beforehand. How can I tell Coq they are indeed the same?

My current goal is like this: 1 subgoal fun1 : forall W : Type, list W -> list W -> list W H_fun1 : S_fun fun1 V : Type h : V t : list V ______________________________________(1/1) fun2 V (fun3 fun2 V t) (h :: nil) = …
Serene M
  • 17
  • 1
0
votes
1 answer

Proving two functions are equivalent without exactly the same hypotheses

First question post! Sorry for any inappropriate format in advance. Trying to prove two versions of functions are the equivalent, I can't proceed after reaching this step. How can I solve this? 1 subgoal a' : nat Ha' : forall b : nat, version1 a' b…
0
votes
2 answers

Proving an addition function is associative using Coq

I am trying to prove that a predefined addition function is associative, but I am stuck at the step where the goal reads plus (S x') (plus y z) = plus (plus (S x') y) z but the only hypothesis I have is : IHx' : forall y z : nat, plus x' (plus y z)…
Serene
  • 1
  • 1
0
votes
1 answer

Coq match on Hypothesis passed to Ltac tactic

I'm new to Coq, currently on the IndProp chapter of Software Foundations. I'm curious about learning to write my own simple tactics to automate certain kinds of reasoning, but unfortunately the official documentation is a bit impenetrable to me as…
Benjamin Bray
  • 416
  • 4
  • 14
0
votes
2 answers

How to group duplicated hypothesis in Coq?

I have 1 subgoals, subgoal 1 n : nat b : bool m : nat H1: P1 H2: P2 H3: P1 H4: P2 ========= some_goal after I run the tactic auto_group_duplicates, it will become 1 subgoals, subgoal 1 n, m : nat b : bool H1, H3: P1 H2, H4:…
DoubleX
  • 351
  • 3
  • 18
0
votes
1 answer

How can I replace a variable by another in coq

When I was trying to prove if two functions are equivalent and come to the step: I : f(S a') b = S (f a' b) f (S a') (S b) = S (f a' (S b)) I am wondering whether it's possible to use exact(I) to prove it, namely, to replace (S b) by b, since…
Serene
  • 1
  • 1
0
votes
1 answer

Is there any way to rewrite the function in "is_lim"?

I'm using Coq and Coquelicot Library, and I'd like to know a better way to handle limit easily. When I want to prove \lim_{x \to 1} (x^2-1)/(x-1) = 2, I code as follows. Require Import Reals Lra. From mathcomp Require Import all_ssreflect. From…
Yosuke Ito
  • 15
  • 3
0
votes
1 answer

Coq: How to use one tactic to appoint instances for multiple existential quantified variables

Suppose I have a goal as follow. exists s0 s3 s4 : list T, s1 ++ s2 = s0 ++ s3 ++ s4 I want to appoint some concrete values for s0, s3, s4 and I am trying exists v1 v2 v3 to do that with v1 v2 v3 already in the proof context. But coq complains…
January
  • 53
  • 6
0
votes
1 answer

Solving a mergesort split proof in Coq

I am currently working on the volume 3 of the Software Foundations' textbook Verified Functional Algorithm and I am stuck on the proof of one exercise. You can find the chapter about Mergesort which I am dealing with at the moment here:…
TalionZz
  • 1
  • 2
0
votes
2 answers

How to prove (~Q -> ~P) - > (P -> Q) in Coq

I am trying to prove (~Q -> ~P) - > (P -> Q) in coq, which is the reverse of the contrapositive theorem (P-> Q) (~Q -> ~P). Currently I was thinking about using the same logic of proving the contrapositive theorem like this: unfold not. intros P Q.…
David
  • 15
  • 4
0
votes
1 answer

Ssreflect probabilities (event and not event) sum to one

I am a beginner and would like your help getting to sum the probability of event F and the probability of event not F to one. Is there a fast way forward? X: {RV (P) -> (R)} F: {set U} H: 0 < Pr P F H0: Pr P F < 1 i: U H1: i \in U === X i * P i *…
Fusen
  • 311
  • 2
  • 3
  • 10