Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] using Ltac to retrieve the name of an induction principle from the type

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] using Ltac to retrieve the name of an induction principle from the type


Chronological Thread 
  • From: Dan Frumin <dfrumin AT cs.ru.nl>
  • To: coq-club AT inria.fr
  • Cc: MAGAUD Nicolas <magaud AT unistra.fr>
  • Subject: Re: [Coq-Club] using Ltac to retrieve the name of an induction principle from the type
  • Date: Tue, 11 Apr 2017 14:47:01 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=dfrumin AT cs.ru.nl; spf=None smtp.mailfrom=dfrumin AT cs.ru.nl; spf=None smtp.helo=postmaster AT smtp1.science.ru.nl
  • Ironport-phdr: 9a23:grO6dRPWr/4jk83/td8l6mtUPXoX/o7sNwtQ0KIMzox0Lfj7rarrMEGX3/hxlliBBdydsKMYzbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZPebgFHiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0vRz+s87lkRwPpiCcfNj427mfXitBrjKlGpB6tvgFzz5LIbI2QMvd1Y6HTcs4ARWdZQsleWDFPDIO7YYQNAeQPMuVWr4fjqVYVsRu+HAysCP/vyjNUiHL727Ax3eQ7EQHB2QwtB9wAv27SrN7oNKkSS/21zKzJzTXFcvhb3iry6IbSchA8pPGMXLRwfNHNxkk0DQ/FlEiQpZbjPzORz+kAtXWQ4el4Ve+3lmIqpRx9riKyysouhYTFnJ8Zx1He+Slkz4s4K8W0RFN0bNOkCpdcqjyWOopsTs8/QGxluzw2xqAGtJO5eiUB1Y4pyATFa/OddoiF+hLjW/iVITd/nH9lY7e/hwqq8US90OH8TdW70FdUoSpDjtbDqGoB1wbO6sSdTPt9+l+t2TeJ1w/N9uFJOV04mKTGJ5I737I9lJUevV7eEiL3gkn6kaCbe0s89uit8evnY7HmppGGN49zjwHzKrkhmsKlAeQlNwgOXm6b9P+g273450H5WqhKgucwkqndqJzaP9gUpralAw9J1YYu8wqwDzC/0NgBgXYHKE9FdwmcgojyO1DOJej4Au2lj1Stljdr3fHGMaf7DpXDNHiQ2IvmKL168gtXzBc55dFZ/ZNdTL8bc9zpXUqkmNXeRjEjLgm1xa6zBNtny4YfX0qEGemDLeXUtQnbtaoUP+CQadpN637GIP8/6qur1CdhlA==

Hi Nicolas,

It seems that the problem boils down to "how to concatenate an identifier
name and a string in Ltac". I had a similar problem and basically I didn't
find any solutions for this.

Do you know how to do this using an .ml module?

Best
Dan

> On 24 Mar 2017, at 14:34, Nicolas Magaud
> <magaud AT unistra.fr>
> wrote:
>
> Hello,
>
> I would like to write a Ltac tactic which, from the type of a variable
> (obtained using the function "type of”), retrieves and applies the
> associated induction principle.
>
> If _x is of type nat, it applies nat_rect; if _x is of type t, it applies
> t_rect (see example below).
>
> So far, I do it using Ltac pattern-matching, which is weird as “t” does not
> belong to an inductive type and my Ltac function has to be extended
> manually each time I handle a new inductive type.
>
> I would prefer something like (type of _x)^”_rect” which appends the
> appropriate extension to the tacexpr1 returned by "type of”.
>
> Is there any way to do that using only Ltac (i.e. without writing any .ml
> or .ml4 files) ?
>
> Nicolas Magaud
>
> ------
> Inductive t:=A|B|C.
>
> Ltac use_pattern _x:= pattern _x;
> match goal with |- (?f _x) =>
> let t:= (type of _x) in
> match t with
> | nat => apply nat_rect
> | t => apply t_rect
> end end.
>
> Parameter P : t -> nat -> Prop.
>
> Lemma l : forall a n, P a n.
> Proof.
> intros.
> use_pattern a.
> Undo.
> use_pattern n.




Archive powered by MHonArc 2.6.18.

Top of Page