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: Beta Ziliani <beta AT mpi-sws.org>
  • To: Coq Club <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: Fri, 24 Mar 2017 10:56:40 -0300
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=beta AT mpi-sws.org; spf=Neutral smtp.mailfrom=beta AT mpi-sws.org; spf=None smtp.helo=postmaster AT juno.mpi-klsb.mpg.de
  • Ironport-phdr: 9a23:y52fuhUA/scY6BAhGb9TcELgH53V8LGtZVwlr6E/grcLSJyIuqrYYxWCt8tkgFKBZ4jH8fUM07OQ6PG8HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjSwbLd9IRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KpwVhTmlDkIOCI48GHPi8x/kqRboA66pxdix4LYeZyZOOZicq/Ye94RWGhPUdtLVyFZAIy8YYsBAeQCM+hFsYfyu1QAoACiBQm1Hu7j1iNEimP00KA8zu8vERvG3AslH98WrXnbssn1O70PWu+2zanIyTTDYOlQ2Tf89YPFdQsuru+QXb1qasfRzFEvFwLcglWLp43lJCmZ1uMXs2iU9udtU/+khW0/qwxpvzSiyMMhhpPUio8R0FzJ9iR0zJw6KNC3TkNwfMSqH4FKty6AMot7WsMiTH9suCY90rAGu4O7fC4NyJg9wh7fc/2Hf5GL4hLnT+aeOi10hHd9eLKwnRq97FavxvX9VsmyzllKsjJInsTCu30JzRDf98yKRuF+80qgwzqC2A/e5vlBIU8ulKrbL5AhwqQ3lpoWqUnMBTH5mFnsg6KNc0Uk4umo5/38YrTovZ+QLYh0ihvxMqg2gMywHfw4MhQSX2ic4emzyLrj/VTgTLpWiv02j7LWvYvBJcUbo665GxVa3pwi6xa5FTem0c4XkWMJLFJfK1q7iN3CPEiGC/TlB7/riFO11Txv2vruP7v7A5yLIGKVw5n7erMowUNAwUIBzNRe7pRVQuULLe76ckrptZnDEQR/NBa7lbW0QO5h358TDDrcSpSSN7nf5BrRvroi

Not really what you're asking, but why aren't you just using the
"elim" tactic for that?

On Fri, Mar 24, 2017 at 10:34 AM, 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