Skip to Content.
Sympa Menu

coq-club - RE: [Coq-Club] Tactic to collect hypothesis of given type in a list

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

RE: [Coq-Club] Tactic to collect hypothesis of given type in a list


Chronological Thread 
  • From: "Soegtrop, Michael" <michael.soegtrop AT intel.com>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: RE: [Coq-Club] Tactic to collect hypothesis of given type in a list
  • Date: Thu, 15 Sep 2016 10:42:48 +0000
  • Accept-language: de-DE, en-US
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=michael.soegtrop AT intel.com; spf=Pass smtp.mailfrom=michael.soegtrop AT intel.com; spf=None smtp.helo=postmaster AT mga07.intel.com
  • Ironport-phdr: 9a23:WqJWKRHUcCuywfKIY5rdY51GYnF86YWxBRYc798ds5kLTJ75p8qwAkXT6L1XgUPTWs2DsrQf2rOQ7P2rAz1Ioc7Y9itdINoUD15NoP5VtjJjKfbNMVf8Iv/uYn5yN+V5f3ghwUuGN1NIEt31fVzYry76xzcTHhLiKVg9fbytScaBx/iwgqq5/ISWaAFVjhK8Z6lzJVO4t0+Z4sIRmM5pLrs74hrPuHpBPepMkzBGP1WWylzH4cq/4IRk62AYnvMq98dNVe+yK6E5RrxRATBgKGc469HxsgHrTA2T639aWWITxEkbSzPZ5Q33C8+i+hDxsfBwjXGX

Dear Coq Users,

using Jonathan's trick to mix Ltac and value returning functions, I came up
with this Ltac function, which collects all hypothesis of a given type,
clears the hypothesis and returns a list of the hypothesis.

Ltac CollectAndClearHypothesis T :=
let rec f l :=
lazymatch goal with
| H1 := ?h1 : T |- _ =>
(* need to wrap the clear H1 in a match goal to mix it with
returning a term *)
let dummy := match goal with |- _ => clear H1 end in
let l' := constr:(h1::l) in f l'
| |- _ => l
end
in f (@nil T).

It is used like this:

let l := CollectAndClearHypothesis PropWrap in idtac l.

Thanks Jonathan!

Best regards,

Michael

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928




Archive powered by MHonArc 2.6.18.

Top of Page