Questions tagged [ltac]

The Ltac language, Coq's domain-specific language for proof search procedures. Use this tag on questions about the language and questions about proof automation using Ltac.

Here are some references on Ltac:

  • The Coq Reference Manual, sect. 9;
  • Certified Programming with Dependent Types by A. Chlipala, the Proof Search in Ltac chapter;
  • The original paper: A Tactic Language for the System Coq by D. Delahaye (‎2000).
72 questions
1
vote
0 answers

Automatically specializing hypotheses in Coq

In proofs, if I perform induction on an argument that is not final, I get universally-quanitified induction hypotheses. I find myself repeatedly writing tactics like this: match goal with | [H : forall (esub : expr) (x : exprvar) (tsub t :…
jmite
  • 8,171
  • 6
  • 40
  • 81
1
vote
1 answer

Ltac: do something different in each goal

I've got a proof script where I'm exploring multiple cases, and it's currently quite slow, since I have a number of strategies for solving the goals, and I'm trying each one in each case. I know that I need to apply certain tactics in certain cases,…
jmite
  • 8,171
  • 6
  • 40
  • 81
1
vote
1 answer

Coq: Defining Vernacular to avoid duplication

I'm currently working on proofs where I find myself writing code like this over and over again: Lemma eq_T: forall (x y : T), {x = y} + {x <> y} with eq_trait: forall (x y : trait), {x = y} + {x <> y} with eq_pi: forall (x y : pi), {x = y} + {x…
jmite
  • 8,171
  • 6
  • 40
  • 81
1
vote
2 answers

How to write an Ltac to multiply both sides of a equation by a group element in Coq

Using this definition of a group: Structure group := { G :> Set; id : G; op : G -> G -> G; inv : G -> G; op_assoc_def : forall (x y z : G), op x (op y z) = op (op x y) z; op_inv_l : forall (x : G), id = op (inv x) x; …
1
vote
2 answers

Instantiating an existential with a specific proof

I'm currently trying to write a tactic that instantiates an existential quantifier using a term that can be generated easily (in this specific example, from tauto). My first attempt: Ltac mytac := match goal with | |- (exists (_ : ?X), _) =>…
user181407
  • 235
  • 1
  • 6
1
vote
1 answer

generalizing expressions under binders

I need to generalize expression under the binder. For example, I have in my goal two expressions: (fun a b => g a b c) and (fun a b => f (g a b c)) And I want to generalize g _ _ c part: One way to do is to rewrite them first into: (fun a b =>…
krokodil
  • 1,326
  • 10
  • 18
1
vote
1 answer

Coq coercions and goal matching

Assume I have the following setup: Inductive exp: Set := | CE: nat -> exp. Inductive adt: exp -> Prop := | CA: forall e, adt e. Coercion nat_to_exp := CE. Ltac my_tactic := match goal with | [ |- adt (CE ?N) ] => apply (CA (CE N)) end. And I try…
Lorenz
  • 1,263
  • 9
  • 20
1
vote
1 answer

Ltac not working after upgrading to Coq 8.5

I have the following Ltac (from here), which used to work on Coq 8.4pl6, but it's not working on Coq 8.5 beta 3: Ltac maybe_intro_sym A B := match goal with |[H:B=A|-_] => fail 1 |[H:A=B|-_] => assert (B=A) by auto end. Ltac…
thor
  • 21,418
  • 31
  • 87
  • 173
0
votes
1 answer

Clear hypotheses after recursive Ltac

I have an Ltac defined as follows. Ltac destruct_list l H := let y := fresh "y" in let x := fresh "x" in let E := fresh "E" in destruct l as [ | x [| y]] eqn:E; simpl in H; inversion H; match goal with | [ Hl : length ?l = 0 |- _] =>…
epelaez
  • 132
  • 10
0
votes
1 answer

Ltac tactic that accepts an arbitrary number of quantifiers

I'm trying to write a--my first--Coq tactic. It should split forall x y z ..., A <-> B into two: forall x y z ..., A -> B and forall x y z ..., B -> A. This is my first attempt: Ltac iff_split H := match type of H with | forall x y, ?A <-> ?B…
Jay Lee
  • 1,684
  • 1
  • 15
  • 27
0
votes
2 answers

How to create a custom Ltac to recursively destruct conjunctions?

I quite often have to deal with complex conjunctions such as (Q /\ W) /\ (E /\ R). I am quite sick of destructing them manually and guessing how to arrange square brackets so I don't accidentally remove some important chunk. I would like to…
radrow
  • 6,419
  • 4
  • 26
  • 53
0
votes
1 answer

Why does Ltac not match the clause?

In the following Coq proof: Ltac easy_ltac t := match goal with | [Z: @eq nat t ?Y |- _ ] => pose ?Y as N end. Lemma easy: forall (n: nat), (n >= O)%nat. Proof. intros n. destruct n eqn: M. easy_ltac n. I get the error message: "No…
Bruno
  • 95
  • 3
0
votes
1 answer

Coq: How are the equality tacticts symmetry and transitivity defined?

I'm interested in how the Coq tactics symmetry and transitivity actually work. I've read the Coq manual but this only describes what they do, not how they operate on a proof and change the proof states. As an example of what I'm looking for, in…
0
votes
1 answer

Adding "in" part to tactic to specify where to apply it

I am new to Coq and to writing tactics, and I have been unable to figure out whether you can define more complicated tactics like the build in ones. For example, say that I have a tactic tac1 taking two arguments, and I define tac2 by Ltac tac2 arg…
Kristian
  • 1,667
  • 2
  • 15
  • 20
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