coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com>
- To: "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 21:37:15 +0000
- Accept-language: en-CA, en-US
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=fdhzs2010 AT hotmail.com; spf=Pass smtp.mailfrom=fdhzs2010 AT hotmail.com; spf=Pass smtp.helo=postmaster AT NAM01-SN1-obe.outbound.protection.outlook.com
- Ironport-phdr: 9a23:mVf79hLlr8J+DVNQRtmcpTZWNBhigK39O0sv0rFitYgeKfrxwZ3uMQTl6Ol3ixeRBMOHs6kC07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffwtFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QLYpUjqg8qhrUgflhicZOTAk7GHZhM9+jKxZrx29qBNy2JTbbJ2JOPdkYq/RYc4WSGxcVchRTSxBBYa8YpMLAeUbJuZYqI/9rEYXoRS9BQmsA+XvyjBVjXHr3a01zeIhEQ7f0Ac9HdwOrWnfodL7NKgPUeC0zbLIwSvfY/9LxTvw84jIchc9ofGJR71wcM7RxVMzGAPCi1WdsIroNC6W2OQVq2WW4PZsWfirhmI5sQ19vCKjy8cyhoXRiIIa1FPJ+Tl8zYswK9C3VUp2bNChHZRKrC6XOZZ6T8Y+TGFmuis6xLgLtoKncyUExpQqwQPUZeadfIiS+B3jUf6cITdmi3Jhf7Kynw68/FSnxOHgS8W4yUtEoDJYntXVsXACzALc5tKASvtg4keuwjGP1x3V6u5ZO0w0jbDbK5k9wrEuipUTrUXDHijwmEnsi6+Wa1kk+uyv6+TgYbXqvIOTN4hxig3mM6QunNKwAfggPwUBQ2SX4+Cx2KP58UHnWrlHjuM6nrHcsJ/AJMQboqC5AxVS0oYm8xu/ASqp0NQZnHkcMl5JZA+Lg5TyNlHOJ/D4EfK/jE6tkDdv3fzJIrrhApDVInjZjLjhZap961JbyAcr0d9f4ItUBqgdL/L3R0/+r8fVDgQ5Mgyx2+boEs9x1oIYWWKVA6+WKrnesVGS5rFnH+7ZLoQSoXP2L+Uvz//ol34w31EHN+H91pwOLXu8A/5OIkODYHOqjM1XQkkQuQ9rbuXxj1vKFAxTYHC9F5k86zc0TcqGEM+XSIytkqfbhH7jNp1RemVPC1TKGnDtIdbXE8wQYT6fd5cy2gcPUqKsHtd4hEOe8TTiwr8iFdL6vygRtJbtzt9wvraBlRYu8DV1C4KW1GTfFjgozFNNfCc/2eVEmWI40k2KiPMqg/tEENVS47VCVQJobceBndw/MMj7X0f6RvnMSFuiRYn5UxcYa4pohuQoOgN6EdjkiQ3f1S23BbNTj6aMGJE/7qPb2T72Otp5zHHFkqImigt/Tw==
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)
To: coq-club AT inria.fr
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
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.