证明常数不是满射的 Coq

发布于 2025-01-16 08:41:46 字数 360 浏览 2 评论 0原文

有一个函数定义常量 {X:Type} (c:X) := fun xy : X => y = c。 证明:定理 const_not_sur :forall c:nat, ~surjective (constant c)。 我做到了:

unfold not.
unfold surjective.
unfold constant.
intros.
destruct (H 1) as [x H1].
destruct x.
induction c.
symmetry in H1.
discriminate.

我还需要使用 n_Sn 定理来证明上面的问题。然而,我花了一个小时却无法让它发挥作用。 有什么建议吗?

there is a function that Definition constant {X:Type} (c:X) := fun x y : X => y = c.
prove that: Theorem const_not_sur : forall c:nat, ~surjective (constant c).
I did:

unfold not.
unfold surjective.
unfold constant.
intros.
destruct (H 1) as [x H1].
destruct x.
induction c.
symmetry in H1.
discriminate.

I also need to use n_Sn theorem to prove above question. However, I spent an hour just can't make it to work.
Any suggestion?

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

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

发布评论

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

评论(3

不疑不惑不回忆 2025-01-23 08:41:46

我认为问题出在你的destruct (H 1)上。如果您的关系constant c 是满射的,那么您可能会通过考虑S c 而不是1 来发现矛盾。

I think the problem comes from your destruct (H 1). If your relation constant c were surjective, then you may find a contradiction by considering S c instead of 1.

顾忌 2025-01-23 08:41:46

与您的常数兼容的满射性定义可能是

Definition surj {X:Type} (R: X -> X -> Prop) := forall y, exists x, R x y.

对的? (或更通用的变量,带有类型变量 XY)。

您还可以考虑以下一对定义:

Definition const X {Y:Type} (k: Y) := fun (x:X)  =>  k.
Definition surj {X Y : Type} (f : X -> Y) := forall y, exists x, f x = y.

Goal forall n: nat,  ~ surj(const nat n).

一般来说,在您的代码片段中包含足够的必要定义(或库的使用)可能会很有用,以便我们能够重播您谈论的脚本。

A definition of surjectivity compatible with your constant could be

Definition surj {X:Type} (R: X -> X -> Prop) := forall y, exists x, R x y.

Right ? (or a more general one, with type variables X and Y).

You may also consider instead the following pair of definitions:

Definition const X {Y:Type} (k: Y) := fun (x:X)  =>  k.
Definition surj {X Y : Type} (f : X -> Y) := forall y, exists x, f x = y.

Goal forall n: nat,  ~ surj(const nat n).

In general it could be useful to include in your snippets enough necessary definitions (or use of libraries) in order to allow us to replay the scripts you talk about.

哥,最终变帅啦 2025-01-23 08:41:46

正如 HTNW 在您之前的一篇文章中已经提到的,问题可能来自于您对 constant 函数的定义。

如果我尝试使用 mathcomp 证明你的定理,我会得到以下观点(我不知道你使用的是哪个版本的 Surjective,所以我复制了一个):

From mathcomp Require Import all_ssreflect.

Lemma equal_f: forall {A B : Type} {f g : A -> B}, f = g -> forall x, f x = g x.
Proof. by move=> A B f g -> y. Qed.

Definition Surjective {A B} (f : A->B) := forall y, exists x, f x = y.

Definition constant {X:Type} (c:X) := fun x y : X => y = c.

Theorem const_not_sur : forall c:nat, ~Surjective (constant c). 
Proof.
move=> c /(_ (fun y => true)) [x] /equal_f /(_ c.+1). 
rewrite /constant.
elim: c => [|c].

在那里我必须证明两个命题相等(它们漂亮地打印为 1 = 0true),这是一个复杂的问题(注意:相等,而不是等价)。

但是,如果您将自己限制为常量定义中具有相等性的类型,并返回布尔值而不是命题,那么您可以完成类似的证明:

Definition constant' {X:eqType} (c:X) := fun x y : X => y == c.

Theorem const_not_sur' : forall c:nat, ~Surjective (constant' c). 
Proof.
move=> c /(_ (fun y => true)) [x] /equal_f /(_ c.+1). 
elim: c => [//|c].
by rewrite /constant' eqSS.
Qed.

我仍然相信问题可能是在于constant的初始定义。

As already mentioned by HTNW in one of your previous posts, the problem may come from your definition of the constant function.

If I try to prove your theorem, using mathcomp, I get to the following point (I don't know which version of Surjective you used, so I copied one):

From mathcomp Require Import all_ssreflect.

Lemma equal_f: forall {A B : Type} {f g : A -> B}, f = g -> forall x, f x = g x.
Proof. by move=> A B f g -> y. Qed.

Definition Surjective {A B} (f : A->B) := forall y, exists x, f x = y.

Definition constant {X:Type} (c:X) := fun x y : X => y = c.

Theorem const_not_sur : forall c:nat, ~Surjective (constant c). 
Proof.
move=> c /(_ (fun y => true)) [x] /equal_f /(_ c.+1). 
rewrite /constant.
elim: c => [|c].

and there I have to prove the equality of two propositions (they prettyprint as 1 = 0 and true), which is a complicated issue (note: equality, and not equivalence).

But, if you limit yourself to types with equality in the definition of constant, and return a boolean value instead of a proposition, then you can complete a similar-looking proof:

Definition constant' {X:eqType} (c:X) := fun x y : X => y == c.

Theorem const_not_sur' : forall c:nat, ~Surjective (constant' c). 
Proof.
move=> c /(_ (fun y => true)) [x] /equal_f /(_ c.+1). 
elim: c => [//|c].
by rewrite /constant' eqSS.
Qed.

I still believe that the problem may lie in the initial definition of constant.

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