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

Coq proof for subtraction does not commute

I would like to prove that subtraction does not commute in Coq but I am stuck. I believe the that the statement I would like to prove in Coq would be written forall a b : nat, a <> b -> a - b <> b - a Here is what I have for the proof so…
Mike Harris
  • 869
  • 9
  • 21
1
vote
1 answer

Split conjunction goal into subgoals

Consider the following toy exercise: Theorem swap_id: forall (m n : nat), m = n -> (m, n) = (n, m). Proof. intros m n H. At this point I have the following: 1 subgoal m, n : nat H : m = n ______________________________________(1/1) (m, n) = (n,…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

Coq: remove constructor from both sides of goal

Consider the following partial proof: Theorem test : forall (n m : nat), n = m -> S n = S m. Proof. intros n m H. Executing until this point gives me the following: 1 subgoal n, m : nat H : n = m ______________________________________(1/1) S n…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

How to rewrite a goal using function definition?

I have this code: Module Type tDecType. Parameter T: Type. Parameter is_eq: T -> T -> bool. Axiom is_eq_reflexivity: forall x, is_eq x x = true. Axiom is_eq_equality: forall x y, is_eq x y = true -> x = y. End tDecType. Module NAT <:…
Lepticed
  • 341
  • 1
  • 11
1
vote
1 answer

A special case of Lob's theorem using Coq

I have a formula inductively defined as follows: Parameter world : Type. Parameter R : world -> world -> Prop. Definition Proposition : Type := world -> Prop (* This says that R has only a finite number of steps it can take *) Inductive R_ends :…
thbl2012
  • 27
  • 5
1
vote
2 answers

How can I automate counting within proofs in Coq?

I have a function count that counts how many times a given predicate is provable when applied to elements of a list. It is defined as follows: Parameter T : Type. Parameter dec: forall (p: T -> Prop) (w: T), {p w} + {~ (p w)}. Fixpoint count (p: T…
Bruno
  • 854
  • 7
  • 21
1
vote
1 answer

Casting types in coq

I have the definition my_def1: Require Import compcert.common.Memory. Require Import compcert.common.Values. Require Import compcert.lib.Integers. Definition my_def1 (vl: list memval) : val := match proj_bytes vl with | Some bl =>…
1
vote
0 answers

How to unfold a Coq Fixpoint literally

I was trying to unfold a Fixpoint definition and obtain the body of the definition. But Coq wouldn't give the body of the definition literally. Instead, it's giving me something starting with (fix ...), which I cannot make use of. For example, in…
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
1 answer

what's the correct usage for Coq "local application of tactics"?

I'm reading Coq reference manual (8.5p1) about Local application of tactics Different tactics can be applied to the different goals using the following form: [ > expr1 | ::: | exprn ] The expressions expri are evaluated to vi, for i = 0; ...; n…
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
1 answer

Coq inversion tactic that works on the goal?

I was wondering if there is an inversion-like tactic in Coq that works on the goal instead of on one of the hypotheses? That is, if there is some tactic that can invert identical constructors in equalities on the goal. For a silly example, Goal…
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
1 answer

rewrite works for integer but not for rationals for Coq aac_tactics

I was testing Coq rewrite tactics modulo associativity and commutativity (aac_tactics). The following example works for integer (Z), but generates an error when integers are replaced by rationals (Q). Require Import ZArith. Import…
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
1 answer

Tactic to partially compute goal in Coq

I have goal quad X Y , but I don't remember definition of "quad" and I don't want to start searching of its definition. Is there a tactic that allow me rapidly substitute quad with its definition? Record quad (X Y:Type):= { x:X; y:Y}. Or I have…
ged
  • 687
  • 7
  • 19
1
vote
1 answer

Is there a convention for the order of applying ssreflect tactic/taticals?

I am trying to understand how combined ssreflect tactics should be "decomposed" (or how they are composed in the first place). One of the problems I have is to understand the order and associativity of the taticals. Sometimes, I feel that the order…
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
1 answer

is there a `eapply`-like tactic that works on `exists` goals in Coq?

I have the following during a proof where the goal is an existential, and the target property is one of the assumptions. H : x ==> y ... ______________________________________(1/2) exists t : tm, x ==> t I know I can do exists y. apply H. to prove…
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
1 answer

How to use an unequality to simplify a if-then-else in Coq?

I am in the middle of a proof, where I generated two cases by destruct (eq_id_dec Y X) (eq_id_dec is similar in nature to eq_nat_dec). This gives two cases with added assumptions e: Y = X for equality and n: Y <> X for unequality, respectively. In…
thor
  • 21,418
  • 31
  • 87
  • 173