基于forall证明较弱的存在

发布于 2025-01-12 15:28:36 字数 349 浏览 1 评论 0原文

Lemma one_bigger' : forall n h, 
   n = S (double h) -> (exists k, S n = double k).
Proof.
  intros n h H.  rewrite H. exists (S h). reflexivity.
Qed.

Lemma one_bigger : forall n, 
   (exists k, n = S (double k)) -> (exists k, S n = double k).
Admitted.

在我看来,考虑到第一个引理,第二个引理应该是可以轻易证明的,但我似乎无法理解如何使用第一个引理来证明第二个引理。

Lemma one_bigger' : forall n h, 
   n = S (double h) -> (exists k, S n = double k).
Proof.
  intros n h H.  rewrite H. exists (S h). reflexivity.
Qed.

Lemma one_bigger : forall n, 
   (exists k, n = S (double k)) -> (exists k, S n = double k).
Admitted.

It seems to me that the second lemma should be trivially provable given the first, but I can't seem to wrap my head around how to use the first lemma to prove the second one.

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

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

发布评论

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

评论(3

赤濁 2025-01-19 15:28:36

case H 似乎是我找不到的魔法:

Lemma one_bigger : forall n, 
   (exists k, n = S (double k)) -> (exists k, S n = double k).
Proof.
  intros n H. case H. apply one_bigger'.
Qed.

case H seems to be the magic I couldn't find:

Lemma one_bigger : forall n, 
   (exists k, n = S (double k)) -> (exists k, S n = double k).
Proof.
  intros n H. case H. apply one_bigger'.
Qed.
单身狗的梦 2025-01-19 15:28:36

事实上,你的例子是一个等价的实例(引理L

Section S1.
  Variable (A :Type).
  Variables (P : A -> Prop) (Q:  Prop).
  
  Lemma L : (forall x , P x  -> Q ) <-> ((exists x, P x) -> Q). 
   Proof.
    split.
    - intros H [x Hx]; now apply (H x).
    - intros H x Hx; apply H. now exists x.
  Qed.
End S1.

Lemma one_bigger'' : forall n, 
    (exists k, n = S (double k)) -> (exists k, S n = double k).
Proof. 
  intros n .
  rewrite <- L . 
  apply one_bigger'. 
Qed. 

Indeed, your example is an instance of an equivalence (Lemma L)

Section S1.
  Variable (A :Type).
  Variables (P : A -> Prop) (Q:  Prop).
  
  Lemma L : (forall x , P x  -> Q ) <-> ((exists x, P x) -> Q). 
   Proof.
    split.
    - intros H [x Hx]; now apply (H x).
    - intros H x Hx; apply H. now exists x.
  Qed.
End S1.

Lemma one_bigger'' : forall n, 
    (exists k, n = S (double k)) -> (exists k, S n = double k).
Proof. 
  intros n .
  rewrite <- L . 
  apply one_bigger'. 
Qed. 
唔猫 2025-01-19 15:28:36

如果您使用 SSReflect,您可以按如下方式编写证明。

From mathcomp Require Import all_ssreflect.

Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Lemma one_bigger' : forall n h, 
   n = S (double h) -> (exists k, S n = double k).
Proof.
  intros n h H.  rewrite H. exists (S h). reflexivity.
Qed.

Lemma one_bigger : forall n, 
   (exists k, n = S (double k)) -> (exists k, S n = double k).
Proof. by move=> n [k /one_bigger']. Qed.

move 构造与 intros 相同,只是您的 H 在这里直接解构为见证人 k ,以及存在性平等的证明。最后一个证明通过 / 表示法直接传递给 one_bigger',从而产生预期的结果。

另一个更明确的证明是

Proof. move=> n [k eqn]. exists k.+1. by rewrite eqn doubleS. Qed.

If you use SSReflect, you can write your proof as follows.

From mathcomp Require Import all_ssreflect.

Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Lemma one_bigger' : forall n h, 
   n = S (double h) -> (exists k, S n = double k).
Proof.
  intros n h H.  rewrite H. exists (S h). reflexivity.
Qed.

Lemma one_bigger : forall n, 
   (exists k, n = S (double k)) -> (exists k, S n = double k).
Proof. by move=> n [k /one_bigger']. Qed.

The move construct does the same as intros, except that your H is here directly destructured into a witness, k, and a proof of the equality in the existential. This last proof is directly passed to one_bigger' via the / notation, thus yielding the expected result.

Another, more explicit proof would be

Proof. move=> n [k eqn]. exists k.+1. by rewrite eqn doubleS. Qed.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文