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

How do I check for convertibility in a tactic producing terms?

Suppose I have the following tactic to check if a term is the literal zero: Ltac isZero x := match x with | O => constr:true | _ => constr:false end. Goal Set. let isz := isZero O in pose isz. (* adds true to the context *) Now imagine…
Clément
  • 12,299
  • 15
  • 75
  • 115
1
vote
3 answers

how to rearrange terms in Coq using plus communtativity and associativity?

I have a general question about how to rearrange terms in Coq. For example, if we have a term m + p + n + p, humans can quickly re-arrange the terms to something like m + n + p + p (implicitly using plus_comm and plus_assoc). How do we do this…
thor
  • 21,418
  • 31
  • 87
  • 173
0
votes
3 answers

Unable to unify "n * 0" with "0"

I'm in the first chapter of Software Foundation. In my attempt to write a simple theorem as follows (It is just an implementation of the built-in theorem mult_n_O): Theorem mult_n_O' : forall n : nat, 0 = n * 0. Proof. intros n. reflexivity. Qed. I…
Pandemonium
  • 7,724
  • 3
  • 32
  • 51
0
votes
1 answer

Domain of a map in Coq

Is it possible to write a function that returns the domain of a map which is defined as follows: Variable A B : Type. Hypothesis A_eqB_dec : forall x y : A, {x = y} + {x <> y}. Definition map := A -> option B.
dvr
  • 370
  • 1
  • 9
0
votes
1 answer

Proving Transitivity of Pointwise Relations on Lists in Coq

In Agda, it's quite easy to prove that if a relation R is transitive then we can define pointwise transitivity on lists: open import Data.List Rel : Set → Set₁ Rel A = A → A → Set private variable A : Set R : A → A → Set data…
0
votes
1 answer

Coerce rat to realType im math-comp/analysis

Is there a way to coerce a rat into a realType (from the math-comp/analysis library)? For example, the notation for coercing a nat is %:R.
dvr
  • 370
  • 1
  • 9
0
votes
2 answers

Syntax error: '.' expected after [vernac:gallina] (in [vernac_aux]) in Coq when using inductive with integers

So I'm trying to define an inductive set in coq that has integers from 0 to 10: Inductive OD : Set := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10. I get this message: Syntax error: '.' expected after [vernac:gallina] (in [vernac_aux]). Nothing I…
user12456500
  • 11
  • 1
  • 2
0
votes
2 answers

Beta expansion in coq: can I make a term into a function, abstracting over another given term?

I want to rewrite a term, as a function in a sort of beta expansion (inverse of beta reduction). So, for example in the term a + 1 = RHS I would like to replace it as (fun x => x + 1) a = RHS. Obviously, the two terms are equal by betta reduction,…
user2506946
  • 131
  • 9
0
votes
2 answers

Proving theorems containing bitwise operators

I'm trying to prove equivalency for a pretty common "bitwise hack", namely: 0 < m /\ land m (m - 1) = 0 -> modulo i m = land i (m - 1): modulo operation optimization for case when m is a power of two. I've managed to get some arithmetic stuff out…
limitedeternity
  • 143
  • 1
  • 6
0
votes
1 answer

Coq `simpl` reduces `S n + m` to `S(n + m)` for free?

I'm just beginning to learn Coq via software foundations. One of the homework Theorems (with my successful proof elided) in Induction.v is: Theorem plus_n_Sm : forall n m : nat, S (n + m) = n + (S m). Proof. (* elided per request of authors…
Reb.Cabin
  • 5,426
  • 3
  • 35
  • 64
0
votes
1 answer

Proving enumerate(...) to range(len(...)) equality

I'm trying to prove the equality of the following Python constructs in Coq: for i, _ in enumerate(l, s) and for i in range(s, len(l) + s) I've made recursive definitions of both enumerate and range functions, also came up with some additional…
limitedeternity
  • 143
  • 1
  • 6
0
votes
1 answer

Is this Lemma true in first-order intuitionistic logic?

I have the following first-order lemma: Lemma nop_firstorder : forall (n n1 n2:nat) (input: list nat), ( (exists p : prog, isValidProg p input -> execProg p [] input = Some [n;n1;n2]) -> (exists p : prog, isValidProg p…
FH35
  • 75
  • 11
0
votes
1 answer

Unfolding terms created with `assert` in Coq

The proof in question can be found here. At the current state, I would like to unfold eqvid and eqvneg in hypothesis eqveq, in order to simplify the projection and obtain a contradictory equality between two different functions. However, these two…
Michele De Pascalis
  • 932
  • 2
  • 9
  • 26
0
votes
2 answers

Cannot apply one hypothesis to another

I am very new to Coq and I'm trying to prove that if two functions are injectives, the composition of theses two functions is also injective. Here is my code: Definition compose {A B C} (g: B -> C) (f: A -> B) := fun x : A => g (f x). Definition…
Romain C
  • 11
  • 1
  • 3
0
votes
2 answers

How to deal with division in COQ?

How to deal with with the division in a goal? Because I have a goal which is clearly true... However I cannot use lia and I think that this is related to the division. 2 ^ k / 2 ≤ 2 ^ k Bellow is my COQ screen:
Breno
  • 135
  • 8