如何在自定义策略中使用自动重复?

How to use auto with repeat in custom tactics?

在我的 coq 开发中,我正在学习如何创建适合我的问题领域的新策略,如 Prof. Adam Chlipala

在那个页面上,他描述了如何通过将 repeat 包裹在响应各种有趣条件的 match 周围来创建强大的策略。 repeat 然后迭代,允许进行深远的推理。

repeat 的使用有一个警告(强调我的):

The repeat that we use here is called a tactical, or tactic combinator. The behavior of repeat t is to loop through running t, running t on all generated subgoals, running t on their generated subgoals, and so on. When t fails at any point in this search tree, that particular subgoal is left to be handled by later tactics. Thus, it is important never to use repeat with a tactic that always succeeds.

现在,我已经有了一个强大的战术,auto。它同样将步骤链串在一起,这次是从提示数据库中找到的。来自 auto 的页面:

auto either solves completely the goal or else leaves it intact. auto and trivial never fail.

嘘!我已经投入了一些精力来管理 auto 的提示数据库,但我似乎被禁止在使用 repeat 的战术中使用它们(即有趣的战术。)

是否有一些 auto 的变体可能会失败,或者以其他方式在循环中正确使用?

例如,也许这个变体在 "leaves [the goal] intact".

时失败了

编辑:将auto合并到循环中并不是"right"的方法(参见),但是auto 版本失败的实际问题可能仍然很有趣。

如@AntonTrunov 所述,您始终可以使用 progress tactical to make the tactic fail if the goal has not been changed. In the case of auto since it is supposed to solve the goal or leave it unchanged, you can also wrap it in solve [ auto ] which will have the same effect because it will fail if auto does not solve the goal completely (here is the doc for solve).