Coq 自动从本地上下文中选择假设

Coq 自动从本地上下文中选择假设,coq,coq-tactic,Coq,Coq Tactic,我有一个带有如下部分的校对脚本: - destruct (IHx1 _ _ H3). subst. destruct (IHx2 _ _ H7). congruence. - destruct (IHx1 _ _ H6). congruence. - destruct (IHx1 _ _ H3). subst. destruct (IHx2 _ _ H7). congruence. - destruct (IHx1 _ _ H6). congruence. - destruc

我有一个带有如下部分的校对脚本:

  - destruct (IHx1 _ _ H3). subst. destruct (IHx2 _ _ H7). congruence.
  - destruct (IHx1 _ _ H6). congruence.
  - destruct (IHx1 _ _ H3). subst. destruct (IHx2 _ _ H7). congruence.
  - destruct (IHx1 _ _ H6). congruence.
  - destruct (IHx  _ _ H2). congruence.
  - destruct (IHx  _ _ H5). congruence.
  - destruct (IHx  _ _ H2). congruence.
  - destruct (IHx  _ _ H8). congruence.
  - destruct (IHx  _ _ H8). congruence.
  - destruct (IHx  _ _ H8). congruence.
  - destruct (IHx  _ _ H8). congruence.
  - destruct (IHx  _ _ H7). congruence.
  - destruct (IHx  _ _ H4). congruence.
  - destruct (IHx1 _ _ H8). congruence.
  - destruct (IHx1 _ _ H5). subst. destruct (IHx2 _ _ H9).

它似乎是使用
的最佳候选要清楚地解决,不幸的是,假设到处都是。如何将各种子证明折叠在一起?

我们只有一个归纳假设的情况可以使用下面的Ltac(参见手册,)来解决:

如果以问号为前缀的变量(例如
?c
?st
)是模式匹配元变量,逗号表示独立假设,旋转栅门符号(
-
)将假设与目标分开。这里我们寻找一个归纳假设
IH
和一个兼容的假设
H
,这样我们就可以将
IH
应用到
H
?c/?st
部件确保
IH
H
兼容

具有两个归纳假设的子目标可以类似地解决:

match goal with
  IH1 : forall st2 s2, ?c1 / ?st \\ s2 / st2 -> _,
  IH2 : forall st2 s2, ?c2 / _ \\ s2 / st2 -> _,
  H1 : ?c1 / ?st \\ _ / ?st'',
  H2 : ?c2 / ?st'' \\ _ / st2
  |- _ => now destruct (IH1  _ _ H1); subst; destruct (IH2 _ _ H2)
end
当然,如果您愿意,您可以将名称绑定到这些自定义战术,对它们使用战术,依此类推:

Ltac solve1 :=
  try match goal with
        IH : forall st2 s2, ?c / ?st || s2 / st2 -> _,
        H : ?c / ?st || _ / _
        |- _ => now destruct (IH  _ _ H)
      end.

请避免将SF练习的完整解决方案放在互联网上!你没看到墙上唯一一件红色的东西吗?我道歉!一有答案,我就编辑我的解决方案。我现在想删除它,但我没有另一个同样好的例子来演示我试图演示的问题。我认为你至少应该编辑名称,使谷歌搜索这个解决方案变得困难。我已经删除了识别问题的信息。对不起,我缺乏判断力:哦
Ltac solve1 :=
  try match goal with
        IH : forall st2 s2, ?c / ?st || s2 / st2 -> _,
        H : ?c / ?st || _ / _
        |- _ => now destruct (IH  _ _ H)
      end.