Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Is it possible to perform tactics in an existential's context from Ltac?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Is it possible to perform tactics in an existential's context from Ltac?


Chronological Thread 
  • From: Gaëtan Gilbert <gaetan.gilbert AT skyskimmer.net>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Is it possible to perform tactics in an existential's context from Ltac?
  • Date: Thu, 28 Jun 2018 10:47:47 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gaetan.gilbert AT skyskimmer.net; spf=Pass smtp.mailfrom=gaetan.gilbert AT skyskimmer.net; spf=None smtp.helo=postmaster AT relay9-d.mail.gandi.net
  • Ironport-phdr: 9a23:oOXjQRP/p1E0p2Yd81kl6mtUPXoX/o7sNwtQ0KIMzox0LfvzrarrMEGX3/hxlliBBdydt6oazbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxlJiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0yRD+s7bpkSAXwhSkaKTA5/mHZhM9+gq1Vrx2upQBwzYHPbYGJN/dzZL/Rcc8USGdDWMtaSixPApm7b4sKF+cPPPxXqJXhp1QUqxuxHQiiBOLryjBTmHD2x7E62PkmHAHJxgMvAc4Ov27SrNnvO6cSUOS1w7LWwjXZc/Nbwiz96IvIcxA6ovGMXLdwcc/Pxkk1DQ/FiEufqZD8Mj6Ty+8DsHCb4vJ+We6yiWMrsQN8riS1yssxiYTEiJgZxk3A+Ch92Io4Jt61RFRmbdOnDpdcrS+XO5dsTs4sQWxlvjsxxKcctp6hZicKzYwqxx7BZPyDdIiF+gjjW/iVIThihHNofKuziAuo/Uil0OL8V8203ExFriVflNnDq3EN2wbV6seZVvtx5kah2TCR2ADP8uxIP104mKjBJ5Mj3rI8jIcfvEfNEyPshUn7iKubel0h+uey6uTnZrvmpoWbN49xkgz+Pb4hldKjAesiNAgCRWeb+eW41LL440L5WqlKg+YtkqnasJHaPscbpq+8Aw9QzIkj8QyzDzG439QEhXUHNk5KeAqbj4j1PFHDOOz3DfCmg1i1jDhrw+3GMab6D5XWLnnDla/hcqxn505dzgoz19Ff6IhOBrEPOvKgEnP24dffF1oyNxG+6+fhEtR0kI0ECkyVBarMH6pRrVaO0c0uJ+OBfpNd7Dn0JuQs4bjhjHszlEUBVbKqzIAUaXW9E+4gJUiFNym/yuwdGHsH61JtBNfhj0ePBGYKNiSCGpkk7zR+M7qISILKR4SjmruEhXnpBZ5HfWNHD1WBCzHuepnWAq5QOhLXGddol3k/bZbkU5UojE/8rwzr0LlmK+/Z4GseuI6xjIEotd2Wrgk78HlPN+rY02yJSDspzHkFQzYnjeVz50l0y1PF3qF+j/0eE9FPtatE

You can do "unshelve instantiate (1 := _)" to get the evar in your goal list, or "instantiate (1 := ?[foo])" to give it a name.

Maybe we could extend the toplevel selector to be able to take names, then you could do "[n]: { tac. tac'. ... }" (after giving it a name).

Gaëtan Gilbert

On 28/06/2018 09:41, Yannick Forster wrote:
Hi all,

Ralf's example works using inline ltac:

  Goal exists (n : nat), n = 2.
    eexists.
    instantiate (1 := ltac:(refine (S _))).

This produces:

  S ?Goal0 = 2

Does this enable your idea again Ralf?

Best
Yannick

On 28/06/18 07:37, Ralf Jung wrote:
Hi John,

I was going to suggest something like

   Goal exists (n : nat), n = 2.
     eexists.
     instantiate (1 := refine (S _)).

because "instantiate" can actually run tactics.  However, the above does not
work, saying

   Instance is not well-typed in the environment of ?n.

I am not sure how to get around that.  It's certainly possible to refine an evar
using new evars, just not this way I guess...

Kind regards,
Ralf

On 27.06.2018 21:58, John Grosen wrote:
I am currently dealing with a problem in which I have an existential
variable in the goal and want to apply a lemma to the goal, but Coq's
unifier is not powerful enough to automatically unify the relevant part
of the lemma with the evar. However, in this particular case, it is
programatically obvious how to unify them, so I would like to write some
Ltac to do so. Imagine this (greatly simplified) example:

   Goal exists (n : nat), n = 2.
     evar (n : nat).
     exists n.
     only [n]: refine (S _).

This works, but I usually don't have a name for the existential
variables I'm dealing with and the automation certainly doesn't know
about any. So what I'd like to do is this:

   Goal exists (n : nat), n = 2.
     eexists.
     match goal with
     | [ |- ?x = _ ] =>
       only [x]: refine (S _)
     end.

However, Coq complains with "No such goal." As far as I can tell, this
is because the argument in "only [_]" is a syntactic identifier.

Then, is there any way to select a goal with a non-syntactic identifier,
like I have in this situation?

Thanks,
John




Archive powered by MHonArc 2.6.18.

Top of Page