coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Kevin Hamlen <hamlen AT utdallas.edu>
- To: <coq-club AT inria.fr>
- Subject: [Coq-Club] Conditionally apply a multi-goal tactic?
- Date: Wed, 23 May 2018 16:25:50 -0500
- Authentication-results: mail3-smtp-sop.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 esa3.hc50-71.r1.ces.cisco.com
- Ironport-phdr: 9a23:8SscLBX64wWQ2+iGYEd/4T5F5v7V8LGtZVwlr6E/grcLSJyIuqrYYxGBt8tkgFKBZ4jH8fUM07OQ7/i7HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba98IRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KptVRTmijoINyQh/W/Xl8J+kqFVrhyvqBNw34Hab4CVOeFifq7eZ94WWXZNU8hTWiFHH4iyb5EPD+0EPetAqofyuUUOrRq4BQKxBu3g0DpIhnvo0q08zu8sFgHG0xYlH9IKrnvUqs74NLoOUe+o1qbIyTHDYOlN2Tvn9ofHbw0hrOiKULltcsTR0VEiGg3Kg1mKt4DpIi6Z2v4Qv2SH9eZsS/qjh3M7pw1rvzSixdkghpPLi44J0FzI6Ct0zJotKdGlVkJ2ZcSoHIZNuy2GLYd6XMwvT39ytConxbALupi2dzUQxps93R7QcfmHfpCI4h39UOaRJi91i2x+eL2liRu+60igxfH8W8WoyVpHrDdJnsPWtnwQzRDc9taISuBn8ki92DaPzBzc6uZeLU8okqrbLoYtwr82lpUNrUTOBiH7lUrsgKOIa0ko5/Kk5/n7brn8uJOQL4p0hRv/MqQqlMy/G+M4Mg0WUmib4+u80bnj8lP/QLhRk/02jrTWv4reJcQfvKG5GBVZ3Zg+5BaiFzumysgXnWEbLFJZfxKKl5TmO1bXIPzhEfi/h0msnyxwyvDdPrzhB43NIWLZnLfge7Z98U9cxxApwdBR/ZIHQo0Gdab4XVa0v9jFBDc4NRa1yqDpEoMu+JkZXDesD7GYNuvyuFqM6+Rnd+mFYYsYvh7gN/Qs4/rnljk0lUJLLvrh5ocedH3tRqcuGE6ee3e52o5QQ1dPhRI3SanRsHPHVDdSY3ioWKdlumMmFI6vCYPKXcagjKHThX7nTK0TXXhPDxW3KVmtb5+NAqtedT6eK8tlmydCWLS8Gdd4iEOe8TTiwr8iFdL6vy0VsZW4jYp4/OSI0xE5qGQxUJ3byTjLRGxv2GgJXDQxmqt4pB4lxw==
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
- [Coq-Club] Conditionally apply a multi-goal tactic?, Kevin Hamlen, 05/23/2018
- RE: [Coq-Club] Conditionally apply a multi-goal tactic?, Jason -Zhong Sheng- Hu, 05/23/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Kevin Hamlen, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Jason -Zhong Sheng- Hu, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Kevin Hamlen, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Jason -Zhong Sheng- Hu, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Kevin Hamlen, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Jason -Zhong Sheng- Hu, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Kevin Hamlen, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Jason -Zhong Sheng- Hu, 05/24/2018
- Re: [Coq-Club] Conditionally apply a multi-goal tactic?, Kevin Hamlen, 05/24/2018
- RE: [Coq-Club] Conditionally apply a multi-goal tactic?, Jason -Zhong Sheng- Hu, 05/23/2018
Archive powered by MHonArc 2.6.18.