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

Unfolding a definition without reduction

The Coq manual states that the unfold qualid tactic unfolds each occurrence of qualid in the goal and replaces it with its beta-iota-normal form. Is there a simple way to unfold a definition without triggering beta/iota reduction?
Ifaz Kabir
  • 134
  • 8
3
votes
0 answers

Locating Tactic Notation

Is it possible to Locate where a Tactic Notation is defined in Coq? I know it is possible to locate base tactics using Locate Ltac basetac, non-tactic notation with queries such as Locate "++". For the notation I'm looking for, I can see it in the…
Ifaz Kabir
  • 134
  • 8
3
votes
1 answer

Can I define a tactic under "coqtop - nois"?

$ coqtop -nois Welcome to Coq 8.7.0 (October 2017) Coq < Ltac i := idtac. Toplevel input, characters 0-4: > Ltac i := idtac. > ^^^^ Error: Syntax error: illegal begin of vernac. I am redeveloping "Coq.Init.Prelude" and "HoTT.Basics.Overture" under…
Hexirp
  • 410
  • 2
  • 11
3
votes
1 answer

What does the "functional induction" tactic do in Coq?

I have used functional induction in this proof that I have been trying. As far as I understand, it essentially allows one to perform induction on all parameters of a recursive function "at the same time". The tactics page states that: The tactic…
Siddharth Bhat
  • 823
  • 5
  • 15
3
votes
1 answer

How to prove theorems about recursive functions of ListMap in coq?

I'm trying to learn to use the ListMap module in Coq. I'm really not sure about proving properties about the keys or values in a ListMap, when the ListMap is created by a recursive function. I feel like I do not know what tactics to use. (* Me…
Siddharth Bhat
  • 823
  • 5
  • 15
3
votes
3 answers

Tactic automation: simple decision procedure

I'm trying to automate a decision procedure for whether an ASCII character is whitespace or not. Here is what I currently have. Require Import Ascii String. Scheme Equality for ascii. Definition IsWhitespace (c : ascii) := (c = "009"%char) \/ (c =…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
3
votes
1 answer

How does elim work in Coq on /\ and \/?

In Coq Tutorial, section 1.3.1 and 1.3.2, there are two elim applications: The first one: 1 subgoal A : Prop B : Prop C : Prop H : A /\ B ============================ B /\ A after applying elim H, Coq < elim H. 1 subgoal A : Prop …
Jian Wang
  • 55
  • 6
3
votes
1 answer

Why can't Coq figure out symmetry of the equality by itself?

Suppose we're trying to formalize some (semi)group-theoretic properties, like this: Section Group. Variable A: Type. Variable op: A -> A -> A. Definition is_left_neutral (e: A) := forall x: A, (op e x) = x. Definition is_right_neutral (e: A) :=…
3
votes
3 answers

Establish isomorphism between finite natural numbers and sigma

I'm here with Coq studying the relations between two types I've defined. The first is something like a finite subset of nat, with just three elements: Inductive N3 := zero | one | two. The second is a sigma type with elements satisfying the…
burionk
  • 43
  • 5
3
votes
1 answer

Hint Rewrite Cannot Infer Parameter

I'm trying to create a Hint Rewrite database for a matrix library I've written. However when I write Hint Rewrite kron_1_r : M_db I get the following error: Cannot infer the implicit parameter m of kron_1_r whose type is "nat". kron_1_r has the…
Rand00
  • 376
  • 1
  • 8
3
votes
1 answer

How to make use of a hypothesis containing forall in Coq?

I am trying to prove the equivalence of P \/ Q and ~ P -> Q, under the assumption of Excluded Middle, Theorem eq_of_or : excluded_middle -> forall P Q : Prop, (P \/ Q) <-> (~ P -> Q). where the Excluded Middle is the following. Definition…
user285827
  • 35
  • 1
  • 3
3
votes
1 answer

Ltac call to "cofix" failed. Error: All methods must construct elements in coinductive types

Require Import Streams. CoFixpoint map {X Y : Type} (f : X -> Y) (s : Stream X) : Stream Y := Cons (f (hd s)) (map f (tl s)). CoFixpoint interleave {X : Type} (s : Stream X * Stream X) : Stream X := Cons (hd (fst s)) (Cons (hd (snd s))…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
3
votes
2 answers

Ltac pattern matching: why does `forall x, ?P x` not match `forall x, x`?

Ltac checkForall H := let T := type of H in match T with | forall x, ?P x => idtac | _ => fail 1 "not a forall" end. Example test : (forall x, x) -> True. Proof. intros H. Fail checkForall H. (* not a forall *) Abort. I would…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
3
votes
1 answer

Curry universally quantified function

I am trying to write a tactic for currying functions, including universally quantified functions. Require Import Coq.Program.Tactics. Definition curry1 := forall A B C, (A /\ B -> C) -> (A -> B -> C). Definition curry2 := forall A B, (forall C, A…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
3
votes
2 answers

How to pull the rhs out of an equality in coq

If I have the following: H : some complicated expression = some other complicated expression and I want to grab u := some other complicated expression without hardcoding it into my proof (i.e., using pose) Is there a clean way to do this in LTac?
k_g
  • 4,333
  • 2
  • 25
  • 40