Ltac: repeating a tactic n times with backtracking

六眼飞鱼酱① 提交于 2020-01-25 00:37:46

问题


Suppose I have a tactic like this (taken from HaysTac), that searches for an argument to specialize a particular hypothesis with:

Ltac find_specialize_in H :=
  multimatch goal with
  | [ v : _ |- _ ] => specialize (H v)
end.

However, I'd like to write a tactic that searches for n arguments to specialize a tactic with. The key is that it needs to backtrack. For example, if I have the following hypotheses:

y : T
H : forall (x : T), x = y -> P x
x1 : T
x2 : T
Heq : x1 = y

If I write do 2 (find_specialize_in H), it might choose x2 to instantiate it, then fail trying to find a second argument. So I need my repeat loop to be able to backtrack with which arguments it chooses to specialize earlier arguments.

Is it possible to do this? How can I make a tactic loop that backtracks with its choices of previous iterations?

来源:https://stackoverflow.com/questions/51905979/ltac-repeating-a-tactic-n-times-with-backtracking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!