是否存在一些Coq策略来防止生成多个相同的子目标?如果不是,是否有可能写出某种策略在生成子目标之后立即消除它们?在Isabelle中,您可以执行以下操作:
apply (tactic {* distinct_subgoals_tac *})
答案 0 :(得分:0)
在不编写OCaml代码的情况下,不可能在事后消除重复,但是您可以创建一个evar,该evar是所有重复数据消除后的子目标的结合。像这样:
Ltac distinct_subgoals_tactical tac :=
let H := fresh in
unshelve epose proof _ as H;
[ |
| tac;
[ (* first split apart the hypothesis containing the conjunction of all previous subgoals *)
repeat match type of H with prod _ _ => destruct H as [? H] end;
(* see if any of them solve the goal *)
try assumption;
(* otherwise, add another conjunct to the hypothesis and use the first part of it to solve the current goal *)
refine (fst H) .. ] ];
[ exact True (* fill the final conjunct with True *)
| repeat apply pair; try exact I .. ].
然后您可以将其作为distinct_subgoals_tactical ltac:(<apply tactic here>)