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
2
votes
0 answers

setoid_rewrite with impl doesn't work with lemmas of type `A -> B`

Example: Require Import Basics. Require Export Setoid. Require Export Relation_Definitions. Set Implicit Arguments. Lemma simple1 (A B : Prop) (f : A -> B) (x : A) : B. Proof. assert (f2: impl A B) by exact f. setoid_rewrite <- f2. exact…
fread2281
  • 1,136
  • 1
  • 11
  • 31
2
votes
0 answers

Automatically dispatching single-case inductive types

I'm trying to learn how to do Coq proof automation à la Chlipala/crush. To this end I wonder what's a convenient approach for automatically breaking down single-case inductive types, for example when solving the following: Goal forall {A B: Prop},…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
2
votes
0 answers

Ltac: repeating a tactic n times with backtracking

Suppose I have a tactic like this (taken from HaysTac), that searches for an argument to specialize a particular hypothesis with: Ltac find_specialize_in H := multimatch goal with | [ v : _ |- _ ] => specialize (H v) end. However, I'd like to…
jmite
  • 8,171
  • 6
  • 40
  • 81
2
votes
1 answer

Ltac: Matching with ltac on hypothesis which contains user defined notations

I have the following definition for an ordType and infix notations for its boolean comparison operators ==, sort -> bool; ltb:…
2
votes
1 answer

Ltac: optional variable name

I would like to write a tactic with an optional variable name. The original tactic looks like this: Require Import Classical. Ltac save := let H := fresh in apply NNPP; intro H; apply H. I would like to give the user an opportunity to…
Tom
  • 834
  • 1
  • 14
  • 24
2
votes
2 answers

unfold notation in ltac

I noticed notations can be treated differently. For example < is just notation for a regular definition and unfold "<" does work as in the following example: Theorem a : 4 < 5. Proof. unfold "<". However, <= is notation associated with the type…
Mei Zhang
  • 1,434
  • 13
  • 29
2
votes
1 answer

Equivalent of `remember (f x) as y eqn:H; clear H; clear x`?

Sometimes I have a proof that is best done by projecting into a different space. At the moment I do the following: remember (f x) as y eqn:H; clear H; clear x. I tried to automate this with Ltac: Ltac project x y := let z := fresh in remember…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
0 answers

`fresh` name: use match result if variable, do something else if it's a constant

In a solver tactic, I'm trying to generate reasonably readable names for the generated hypotheses (so things are at least somewhat readable in cases where the automation fails). fresh is happy with identifiers or strings, but doesn't like…
nobody
  • 4,074
  • 1
  • 23
  • 33
1
vote
1 answer

Coq: Ltac for transitivity of implication (a.k.a. hypothetical syllogism)

This question is about a project that I am doing, namely, to code Principia Mathematica in Coq. Principia has derived rules of inference, one of which is Syll: ∀ P Q R : Prop, P→Q, Q→R : P→R I am trying to create an Ltac script that codifies the…
1
vote
1 answer

Remove All Double Negations in Coq

I would like to systematically remove all double negations which can appear in my hypotheses and goals. I know that ~~A -> Ais not a part of intuitionist logic, but the course I am taking is classical, so I don't mind. I am aware that the mentioned…
mlg556
  • 419
  • 3
  • 13
1
vote
2 answers

Splitting a premise with conjunction conclusion in Coq

I often have to do "induction loading" to prove goals in Coq, where I prove multiple things simultaneously by induction. The problem is, I often end up with Inductive Hypotheses of the following form: forall a1 ... an, Premise1 -> Premise2 -> ...…
jmite
  • 8,171
  • 6
  • 40
  • 81
1
vote
2 answers

Conditional Proof Tactic in Coq

I believe the title is pretty self explanatory : https://en.wikipedia.org/wiki/Conditional_proof I would like to have a tactic where I assume a proposition and proceed to find another one, if succeeded, then I have found that the first proposition…
mlg556
  • 419
  • 3
  • 13
1
vote
2 answers

Why does Adam Chlipala use left-associated nested tuples to represent Ltac lists in CPDT?

Via CpdtTactics.v: [...] Succeed iff x is in the list ls, represented with left-associated nested tuples. Ltac inList x ls := match ls with | x => idtac | (_, x) => idtac | (?LS, _) => inList x LS end. This seems atypical. Doesn't…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
0 answers

Coq: Port a Ltac tactic using CPS style to an ML tactic (OCaml plugin)

I'm trying to port a Coq tactic (currently written in Ltac) to OCaml, in order to be able to extend that tactic more easily (and avoid the hacks I needed to emulate in Ltac some data structures that are otherwise quite standard in OCaml). I am…
ErikMD
  • 13,377
  • 3
  • 35
  • 71
1
vote
2 answers

Coq: performing inversion on Prop for Set when there is only one case

Suppose I have some programming language, with a "has type" relation and a "small step" relation. Inductive type : Set := | Nat : type | Bool : type. Inductive tm : Set := | num : nat -> tm | plus : tm -> tm -> tm | lt : tm -> tm -> tm | ifthen :…
jmite
  • 8,171
  • 6
  • 40
  • 81