如何在 Coq 中证明既不是单射也不是满射的常数函数?

How to prove a constant function that neither injective nor surjective in Coq?

所以给出的定义是: Definition constant {X:Type} (c:X) := fun x y : X => y = c. 我需要为 Theorem const_not_inj : forall c:nat, ~injective (constant c).

生成证明

我是这样开始证明的:

Theorem const_not_inj : forall c:nat, ~injective (constant c).
unfold injective.
unfold not.
intros.
induction c.

然后我就卡住了,不知道如何继续。 任何想法都会有所帮助:)

让我们考虑一个 X -> Yc:Y 类型的函数。令 Kc 为常数函数 returns c.

如果X中存在两个不同的元素x0x1,并且如果fun _ => c是单射的,则命题Kc x0 = Kc x1将蕴含x0 = x1,因此矛盾。

对于问题的满射方面,您必须考虑 Y 的居民人数(至少 2)。

根据 Pierre 的建议,您可以将 01 传递给您在 intros 之后得到的 H 假设,从而得到矛盾。 SSReflect 中的一个简短证明是:

From mathcomp Require Import ssreflect ssrfun. 

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

Theorem const_not_inj : forall c:nat, ~injective (constant c).
Proof. by move=> c /(_ 0 1 erefl). Qed.

注意erefl是同项相等的证明。