Coq 应用策略找不到变量的实例

Coq 应用策略找不到变量的实例,coq,Coq,我一直在各种场景中尝试apply策略,在如下情况下,前提是这样的: H1 : a H2 : a -> forall e : nat, b -> g e ============================ ... 当我尝试在H1中应用H2时。,它给出了错误: Error: Unable to find an instance for the variable e. 我可以带到所有e:nat,b->ge作为前提的一部分。这是上述场景的完整工作代码: Lemma

我一直在各种场景中尝试
apply
策略,在如下情况下,前提是这样的:

  H1 : a
  H2 : a -> forall e : nat, b -> g e
  ============================
   ...
当我尝试在H1中应用H2时。,它给出了错误:

Error: Unable to find an instance for the variable e.
我可以带
到所有e:nat,b->ge
作为前提的一部分。这是上述场景的完整工作代码:

Lemma test : forall {a b c : Prop} {g : nat} (f : nat -> Prop),
    a /\ (a -> forall {e : nat}, b -> f e) -> c.
Proof.
  intros a b c f g.
  intros [H1 H2].
  (* apply H2 in H1. *)
Abort.
Coq参考手册:

ident中的策略
apply
term
in
ident尝试将ident类型的结论与术语类型的非依赖前提相匹配,从右到左进行尝试。如果成功,则用术语类型的结论替换假设标识声明

现在,将上述描述应用到您的案例中,我们得到以下结果,Coq试图用
H2
的结论替换
H1:a
,即
ge
。要做到这一点,它需要用一些值实例化通用量化变量
e
,Coq显然无法推断这些值——因此您看到了错误消息

另一种方法是尝试另一种不同的
apply。。。在…

eapply H2 in H1.
这将为您提供两个子目标:

  ...
  H2 : a -> forall e : nat, b -> g e
  H1 : g ?e
  ============================
  c

第一个子目标的
H1
假设显示了普通
apply in
策略的Coq结果,但在
eapply in
案例中,变量
e
被存在变量(
?e
)取代。如果你还不熟悉存在变量,那么它们就是你向Coq做出的承诺,你将在以后为它们建立术语。您应该通过统一隐式地构建术语

无论如何,
专门化(h2h1)。
可能是您想要做的事情,或者类似的事情

pose proof (H2 H1) as H; clear H1; rename H into H1.

就像@AntonTrunov说的:
专门化(h2h1)。
pose proof (H2 H1) as H; clear H1; rename H into H1.