Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Pattern matching against forall / arbitrary arity functions

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Pattern matching against forall / arbitrary arity functions


chronological Thread 
  • From: Adam Chlipala <adamc AT csail.mit.edu>
  • To: "Edward Z. Yang" <ezyang AT mit.edu>
  • Cc: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Pattern matching against forall / arbitrary arity functions
  • Date: Thu, 08 Dec 2011 18:16:57 -0500

Edward Z. Yang wrote:
I recently found myself writing the following tactic:

(**)
Ltac exbamf := match goal with
                  | [ H : _ ->  exists _, _ |- exists _, _ ] =>  destruct H
                  | [ H : forall _, _ ->  exists _, _ |- exists _, _ ] =>  
edestruct H
                  | [ H : forall _ _, _ ->  exists _, _ |- exists _, _ ] =>  
edestruct H
                  | [ H : forall _ _ _, _ ->  exists _, _ |- exists _, _ ] => 
 edestruct H
                end.
(**)

Is there a way to write this more cleanly?

It's easy enough to do with a recursive Ltac function, where you start the recursion by passing the type of [H]. Let me know if you'd like more detail.

P.S.: It's nicer to write [ex _] instead of [exists _, _]. Though in theory this catches more uses of the underlying type family [ex], to me the real benefit is brevity.



Archive powered by MhonArc 2.6.16.

Top of Page