在COQ中,有没有办法方便地证明假设的前提?

发布于 2025-01-24 09:56:37 字数 589 浏览 3 评论 0原文

我有h:p - > q在我的证明上下文中,我需要q完成我的证明,但是我没有任何p:

是否有策略或其他任何可以 使前提p一个新目标,然后替换p - > Q带有q 在证明目标p之后。 然后,我可以直接使用Q来证明原始目标。

但是,我也可以使用断言(HP:P) 然后使用(HP)获取Q,但是我必须手动复制p,这是不便的(尤其是当> 时p是长的,h:p - > q仍然存在)。

我阅读 this 那。

I have H : P -> Q in my proof context, and I need Q to complete my proof, but I don't have any evidence of P:

Is there a tactic or anything else that can
make the premise P a new goal, then replace P -> Q with Q
after the goal P was proved.
Then I can use Q directly to prove the original goal.

However, I can also use assert (HP : P)
then use (H HP) to get a Q, but I have to copy P by hand, it is inconvenient (especially when P is long, and H : P -> Q is still there).

I read this but got nothing useful, maybe I miss that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凯凯我们等你回来 2025-01-31 09:56:37

我认为您正在寻找的是Tactic 应用

I think that what you are looking for is the tactic apply.

慢慢从新开始 2025-01-31 09:56:37

我同意Pierre Jouvelot的观点,您正在寻找应用 tactic(我邀请您接受他的答案)。为了补充这个答案,我将在您的问题所暗示的那样提出一些更接近前进的推理。

您不需要了解以下内容,但它定义了执行您想要的 forward 策略:

Ltac forward_gen H tac :=
  match type of H with
  | ?X → _ => let H' := fresh in assert (H':X) ; [tac|specialize (H H'); clear H']
  end.

Tactic Notation "forward" constr(H) := forward_gen H ltac:(idtac).
Tactic Notation "forward" constr(H) "by" tactic(tac) := forward_gen H tac.

然后,您可以应用forward h来生成p的目标。在最初的目标中,h:p - > Qh:q取代。

I agree with Pierre Jouvelot that you are looking for the apply tactic (and I invite you to accept his answer). To complement this answer, I will propose something closer to forward reasoning as your question implies.

You don't need to understand the following but it defines a forward tactic that does what you want:

Ltac forward_gen H tac :=
  match type of H with
  | ?X → _ => let H' := fresh in assert (H':X) ; [tac|specialize (H H'); clear H']
  end.

Tactic Notation "forward" constr(H) := forward_gen H ltac:(idtac).
Tactic Notation "forward" constr(H) "by" tactic(tac) := forward_gen H tac.

Then you can apply forward H to generate a goal for P. In the original goal, H : P -> Q is replaced by H : Q.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文