coq-club AT inria.fr
Subject: The Coq mailing list
List archive
[Coq-Club] using Ltac to retrieve the name of an induction principle from the type
Chronological Thread
- From: Nicolas Magaud <magaud AT unistra.fr>
- To: coq-club AT inria.fr
- Cc: MAGAUD Nicolas <magaud AT unistra.fr>
- Subject: [Coq-Club] using Ltac to retrieve the name of an induction principle from the type
- Date: Fri, 24 Mar 2017 14:34:18 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=magaud AT unistra.fr; spf=Pass smtp.mailfrom=magaud AT unistra.fr; spf=None smtp.helo=postmaster AT mailhost.u-strasbg.fr
- Ironport-phdr: 9a23:XjHWeh8I4raze/9uRHKM819IXTAuvvDOBiVQ1KB41+McTK2v8tzYMVDF4r011RmSDNmds6oMotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2e2//5Lebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTFUACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMNboRr4oRzut86ZrSAfpiCgZMT457HrXgdF0gK5CvR6tuwBzz4vSbYqINvRxY7ndcMsaS2VdUchfSiJPDICiYYQACOQMJvpYr5D4p1cSrRuyGQuhCeXywTFInH/22qg63vw5HwHHwAMgGNYOv27PrN7oM6kdS++1w7PVzTrecvhb3jL955LHch87vPGDQKl9cdfXyUkuDAPFkk+Qppb/MzObzOQAqm6W5PdjW+K3k2Mrtg98riS1ysoujoTFnJwZxk7a+Slj3oo5OMO0RFZmbdOqDJdcrSOXOo9sTs8+WW1luSY3x7sbspChZicK0o4oxxvHZvyHbYeI5hXjWf6UIThihXJlfLK/hxGp8Ui80OH8S9C40E1WripfiNbMrWsC1xPJ5siJUPtx5kah2TCR2ADP8uxIPE45mbbBJ5MjxrM8jIQfvVrdEiPshkn6kbGael0h+uey6uTnZrvmpoWbN49xkgz+N74hmsOlDuQlLwcDRHWb+eK91L344U35Wq9Fguc4kqnDqJzaP9gUpralAw9J1YYu8wqwDzC/0NgBgXYHKE9FdwmcgojyO1DOJej4Au2lj1Stljdr3fHGMaf7DpXDNHiQ2IvmKL168gtXzBc55dFZ/ZNdTL8bc9zpXUqkkt3TCRswKESRyunuFdk1goYXVmuSDoeENqLJrUWBoOw1dbrfLLQJsSrwfqB2r8XlimU0zBpEJfGk
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.
- [Coq-Club] using Ltac to retrieve the name of an induction principle from the type, Nicolas Magaud, 03/24/2017
- Re: [Coq-Club] using Ltac to retrieve the name of an induction principle from the type, Beta Ziliani, 03/24/2017
- Re: [Coq-Club] using Ltac to retrieve the name of an induction principle from the type, Pierre Courtieu, 03/25/2017
Archive powered by MHonArc 2.6.18.