Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Conditionally apply a multi-goal tactic?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Conditionally apply a multi-goal tactic?


Chronological Thread 
  • From: Kevin Hamlen <hamlen AT utdallas.edu>
  • To: Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com>, "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Conditionally apply a multi-goal tactic?
  • Date: Wed, 23 May 2018 17:16:34 -0500
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=hamlen AT utdallas.edu; spf=Pass smtp.mailfrom=hamlen AT utdallas.edu; spf=None smtp.helo=postmaster AT esa1.hc50-71.r1.ces.cisco.com
  • Ironport-phdr: 9a23:bog9rB9PTRcYV/9uRHKM819IXTAuvvDOBiVQ1KB30OocTK2v8tzYMVDF4r011RmVBd6ds6oMotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2O2+55Pebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTFUACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMMvrRr42RDui9b9mRgL2hicJNzA382/ZhcJ/g61ZvB2hpgdyzJTIbIyPLvdyYq3QcNMcSGFcXshRTStBAoakYoUKEeUBI+dYr4/grFUMtxS+AA2sC/3pyjRVgXL23bc10+ElEQ7Y2gwtBM8OsGjJo9rvMKcSVfq6zLLSwTrdcvxWxC7w5Y7VeR4iufGBRbx9fMrLxUUyFg7Jkk+cpI37Mz+Py+gAsHCX4/d8We61lmIqqB99riKty8swkIXFm4wYxkzc+Slk3oo4Ice0RFNmbdK4CpdcqS6XO5VsTs8/TGxluyA3waAct5GhZigF0pEnygbfa/OZd4iI5QruW/iKIThimX5pYrK/iAqy/ES80+HxVNS43ExQriZYiNXDqm4C1wfJ5sebS/t95Vuu2TGV2w/P7eFEJFg4lavdK5E/3r49jpQevETZEiPrmUj6kLWae0Q69uSy9ujqYa3qppqGOI91jgH+PL4umsu6AekgMggBRW2b+eCi273l5kD5XalKgeAsnandtJDVP98bqrSnDABIz4Yv8wy/ACu+0NQEgXkHK0pIdw6Aj4jwIl3BPPT4DeqkjFm3izdqx/XGPqX7DZnXL3jDlq3hfbdn5EJGxgoz14MX25UBKLgaJ/S7H33xs9rXRiQ5Pgq7hq7HFZ0p2I8eS3nVWvbBGKPVrVqB5+ZpKO6JMstd8j36Mr0u4+PkpX4/g14UO6ezl9NDY3ehW/9iPk+xYHz2g95HH31c7SQkS+m/q1CcUDgbR3+3W686rmU7AYeiAIHrW5yhibiF1Tz9E5FLMDMVQmuQGGvlIt3XE8wHbzifd5c4w240EIO5Qopk7imA8Qrzyr5pNO3Ro3FKqI7v3dxx7vaVmB0vp2UtU5atllqVRmQxpVsmAics1fkj81Fhxl6H1aFjxfFUCI4Lvq4bYkIBLZfZitdCJZXyVwbGJY7bRU2vG5OmCmxpC41ohcVXJU1wAJOpjwvI2GyhBLpHz7E=

Hi Jason,

In my case, my tactic uses "cycle" and "swap" after repeated "destruct" to reorganize the goal order.  When the number of goals is large, and there is a more natural order than the one yielded by "destruct", this can be very useful.  Otherwise one must manually find and focus each logically "next" goal out of a sea of perhaps hundreds of goals, which can be very tedious.

However, my question also applies to any tactic that consults "numgoals" (e.g., to constrain goal explosions), even if the tactic doesn't do any goal-reordering.  It's not clear to me why tactics like "||" must restrict focus to a single goal even when the tactics on which they operate are applicable to multiple goals.

Best,
Kevin




On 5/23/2018 4:37 PM, Jason -Zhong Sheng- Hu wrote:
Hi Kevin,

This way of constructing auto tactics makes me curious. How do you use `cycle` in your tactic? Would the use of that be substantially useful?

Thanks,
Jason Hu


-------- Original message --------
From: Kevin Hamlen <hamlen AT utdallas.edu>
Date: 5/23/18 17:27 (GMT-05:00)
Subject: [Coq-Club] Conditionally apply a multi-goal tactic?

Dear Coq Users,

I have a tactic T that operates on multiple goals as a group (e.g., it
uses the "cycle" tactic).  I would like to repeatedly apply this tactic
until it fails or there are no more focused goals.  How can I do so?

I first tried the obvious:  "all: repeat T."

But that doesn't work because "repeat" cancels the "all" specifier,
narrowing the proof scope to one goal at a time, and preventing T from
operating on multiple goals.  One can verify this by executing the
following:

Ltac showgoalcount := let g:=numgoals in idtac g.

Goal True /\ True.
split.  all: repeat showgoalcount.  (* prints two 1's instead of a 2 *)
Abort.

I then tried a recursive ltac:

Ltac myrepeat T :=
   let n := numgoals in (guard n=0 || (showgoalcount; T; myrepeat T)).

But that doesn't work either, because "||" also cancels the "all"
specifier, which one can verify by executing this:

Goal True /\ True.
split.  all: myrepeat reflexivity.  (* prints two 1's instead of a 2
then a 1 *)
Qed.

Similar experiments reveal that "try", "tryif", and "first" all fail for
the same reason.

The only partial solution I can find is the following (rather
ridiculous) use of "do":

Ltac crazyrepeat T :=
   let n:=numgoals in do n (showgoalcount; T; crazyrepeat T).

This actually works when T never fails, because "do n ..." has the
desired effect of succeeding without doing anything when n=0, yet it
keeps all goals in focus when n>0.  But failures of T cause the whole
tactic to fail instead of making progress; and this solution scales out
of control when the number of goals is large, since it queues n
recursive calls on every iteration, resulting in an exponential number
of iterations.

Is there any solution?

Best regards,
Kevin





Archive powered by MHonArc 2.6.18.

Top of Page