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: Jonathan Leivent <jonikelee AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Tactic to collect hypothesis of given type in a list
  • Date: Wed, 14 Sep 2016 12:43:21 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qk0-f178.google.com
  • Ironport-phdr: 9a23:Iq0gKxcgkV/pRsHMIhO4dvF7lGMj4u6mDksu8pMizoh2WeGdxc6/Yx7h7PlgxGXEQZ/co6odzbGH6ua/Aidbvt7B6ClEK80UEUddyI0/pE8JOIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0IufrymUrDbg8n/7e2u4ZqbO1wO32vkJ+wpZ07p5UWJ749N0NMkcv5wgjLy4VJwM9xMwm1pIV/B1z3d3eyXuKBZziJLpvg6/NRBW6ipN44xTLhfESh0ezttvJ6j5lH/Sl6E4WJZWWELmDJJBRLE5Vf0RMTfqCz/48h63iCGPcTwBZQ5WCqv6bsjHB3vjiYEOjo0/UnYj8VxiORQpxf39E83+JLdfIzAbKk2RajaZ95PHWc=



On 09/14/2016 12:34 PM, Soegtrop, Michael wrote:
Dear Coq Users,

I need a tactic to collect all hypothesis of a given type in a list. The
un-elegant and restricted version below somehow works, but I am looking for
something which would work for any number of hypothesis.

I wanted to use a recursive function and clear the hypothesis in each step
(this would be ok), but as far as I know an Ltac function can either return a
value or manipulate the goal but not both.

Does someone have something similar?

There is Gregory Malecha's plugin, which can be used to iterate over hypotheses: https://github.com/gmalecha/coq-ltac-iter

Without plugins, I have a set of tactics that can get a list of the current hypotheses and iterate over them, including filtering by type. But, they're somewhat kludgey - depending on tactic-in-term behaviors.

Also, there is a way that an Ltac tactic can both return a value and manipulate the goal - using a dummy let that is assigned a trivial match where the branch does the manipulation:

let dummy := match goal with _ => manipulating_tac end in
let result := ... in result.

-- Jonathan



Alternatively an example for constructing a list in a hypothesis by keeping
the tail an evar would be useful. I tried a few things but always get typing
errors, when I instantiate an existing evar with something like head ::
newevar.

Thanks & best regards,

Michael


Open Scope list_scope.

Inductive PropWrap : Prop :=
| SomeProp {P : Prop} (p : P)
| NoneProp
.

Ltac CollectPropWrap :=
lazymatch goal with
| H1 := ?h1 : PropWrap, H2 := ?h2 : PropWrap, H3 := ?h3 : PropWrap |- _ =>
constr:(h1::h2::h3::nil)
| H1 := ?h1 : PropWrap, H2 := ?h2 : PropWrap |- _ =>
constr:(h1::h2::nil)
| H1 := ?h1 : PropWrap |- _ =>
constr:(h1::nil)
end.
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