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: Matthieu Sozeau <mattam AT mattam.org>
  • 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 15:06:56 +0000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mattam AT mattam.org; spf=Pass smtp.mailfrom=matthieu.sozeau AT gmail.com; spf=None smtp.helo=postmaster AT mail-ua0-f170.google.com
  • Ironport-phdr: 9a23:nHJ8oxWfEnhdYJtc9pShkwdz+GvV8LGtZVwlr6E/grcLSJyIuqrYYxGHt8tkgFKBZ4jH8fUM07OQ6PG8HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjSwbLd9IRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KpwVhTmlDkIOCI48GHPi8x/kqRboA66pxdix4LYeZyZOOZicq/Ye94RWGhPUdtLVyFZDYy8YYkAAeoPM+hbsofzuUcBoACkCgWwHu7i0CNEimP00KA8zu8vERvG3AslH98Wt3rbtsn1NLsSUeC00qbI0CjIYe5R2Tb89ofHaA0hquyLULJ1a8XR1VUvGBnAjliLrIzqJS+V1vgXvGie9eZgUvivi2E+pgx3vzOhxd8sh5HXio4Jzl3I7yZ0zYYvKdGmVUJ2Y8SoHIZSui2GMYZ9X9ksTHtyuCkgz70LoZ67czYOyJQg3xPfbuaIc4mM4h76SeaeOyt0iGtreL6ihRu+7VKsyuL7Vsmz31ZKqjRKnsPQuXAK0hzf8smHSv1j8Ue9wTuDyRzf5+VeLU03lafXMYAtzqMym5YJrEjOHDP6lF3zjKCMd0Uk/uao6/7gYrXjvpKcMpV7ih3iMqQum8ywH/k4PhIVX2ic+OWzyqfs/VDiTbVFi/05iKjZsJTAKcsHoa65BhdZ0pw/5BanEzemzNMYkGEbI1JCYRKLlpTmO1XTIP/jFvq/mFStkDJzx//cJLHhA5PNLmLCkLj7Z7p95VRcm0IPyoVU4IsRAbUcKtryXFXwvZrWFEwXKQuxlsPuFMl9144DEVmIEKKQLeuGtFaU+usqC+yFeJMcvXD6MfdztK2mtmMwhVJIJfrh5pAQcn3tW60+e0g=

Hi Nicolas,

  you could associate a typeclass instance to each induction principle and key the class by the associated inductive type.
-- Matthieu

On Tue, Apr 11, 2017 at 2:47 PM Dan Frumin <dfrumin AT cs.ru.nl> wrote:
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