IH 不能用作什么提示。在 Coq 中,当使用 eauto 直接给出归纳假设时意味着什么?

发布于 2025-01-15 10:11:33 字数 1559 浏览 3 评论 0原文

看到相关问题引理不能用作提示但没有看起来超级有用+似乎更好地问新人,向那里的海报提出不相关的问题。我尝试做简单的引理:

  From mathcomp Require Import all_ssreflect.
  Require Import ZArith.
  From Hammer Require Import Tactics.
  From Hammer Require Import Hammer.

  Theorem n_plus_0_eq_n_sketch1:
  forall n:nat,
    n + 0 = n.
  Proof.
    have IH: forall P : nat -> Prop, P 0 -> (forall n : nat, P n -> P n.+1) -> forall n : nat, P n. by apply nat_ind. (* succeeds *)

    
    (* close target with guessed lemmas **)
    (* by sauto use: IH. *) (* fails *)
    by eauto using IH. (* Gives error, IH cannot be used as a hint. *)

但是 eauto 策略给出了错误:

IH cannot be used as a hint.

为什么会这样?我给出的引理有什么问题?

我已经让它在其他情况下工作,所以我很困惑:

  Theorem add_comm_eauto_using:
    forall n m: nat,
      n + m = m + n.
    Proof.
      intros. 
      assert (H: forall n, n + 0 = n) by eauto using n_plus_zero_eq_n.
      assert (H': forall n m, S (n + m) = n + S m) by eauto using Sn_plus_m_eq_n_plus_Sm.
      induction n.
      - eauto using H, H'.
      - 
      (* auto using IHn, H, H'.  *)
      simpl.
      (* auto using IHn, H, H'. *)
      rewrite IHn.
      auto using H, H'.
    Qed.

是否有一些 eauto 之类的细节无法统一目标和我的引理之类的东西?


ref:

Saw related question Lemma cannot be used as a hint but didn't seem super useful + seemed better to ask new that ask unrelated questions to posters there. I tried doing the trivial lemma:

  From mathcomp Require Import all_ssreflect.
  Require Import ZArith.
  From Hammer Require Import Tactics.
  From Hammer Require Import Hammer.

  Theorem n_plus_0_eq_n_sketch1:
  forall n:nat,
    n + 0 = n.
  Proof.
    have IH: forall P : nat -> Prop, P 0 -> (forall n : nat, P n -> P n.+1) -> forall n : nat, P n. by apply nat_ind. (* succeeds *)

    
    (* close target with guessed lemmas **)
    (* by sauto use: IH. *) (* fails *)
    by eauto using IH. (* Gives error, IH cannot be used as a hint. *)

but the eauto tactic gives the error:

IH cannot be used as a hint.

Why is that? What's wrong with the lemma I am giving it?

I've had it work in other cases so I'm puzzled:

  Theorem add_comm_eauto_using:
    forall n m: nat,
      n + m = m + n.
    Proof.
      intros. 
      assert (H: forall n, n + 0 = n) by eauto using n_plus_zero_eq_n.
      assert (H': forall n m, S (n + m) = n + S m) by eauto using Sn_plus_m_eq_n_plus_Sm.
      induction n.
      - eauto using H, H'.
      - 
      (* auto using IHn, H, H'.  *)
      simpl.
      (* auto using IHn, H, H'. *)
      rewrite IHn.
      auto using H, H'.
    Qed.

Is it some detail of how eauto like it can't unify the goal and my lemma or something?


ref:

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

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

发布评论

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

评论(1

听不够的曲调 2025-01-22 10:11:33

eauto 通过匹配头符号来工作。不幸的是
IH 的头符号是一个变量 P 所以这就是您收到错误的原因(请参阅这里

这是被接受的,但没有解决目标

have IH1 := IH (fun n => n + 0 = n).
eauto using IH1.

eauto works by matching head-symbols. Unfortunately the
head symbol of IH is a variable P so this is why you are getting an error (see here)

This is accepted but does not solve the goal

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