不能将一个假设应用于另一个假设

发布于 2025-01-28 20:29:48 字数 1692 浏览 4 评论 0原文

我对CoQ非常陌生,并且正在尝试证明,如果两个功能是iNDIVES,则这些功能的组成也是iNjective。 这是我的代码:

Definition compose {A B C} (g: B -> C) (f: A -> B) :=
  fun x : A => g (f x).

Definition injective {A B} (f: A -> B) :=
  forall x1 x2, f x1 = f x2 -> x1 = x2.

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

Theorem example {A B C} (g: B -> C) (f: A -> B) :
  injective f /\ injective g -> injective (compose g f).
Proof.
  intros.
  destruct H as (H1,H2).
  cut (forall x1 x2: A, (compose g f) x1 = (compose g f) x2).
  intros.
  unfold compose in H.
  unfold injective in H2.

结果是:

2 goals
A : Type
B : Type
C : Type
g : B -> C
f : A -> B
H1 : injective f
H2 : forall x1 x2 : B, g x1 = g x2 -> x1 = x2
H : forall x1 x2 : A, g (f x1) = g (f x2)
______________________________________(1/2)
injective (compose g f)
______________________________________(2/2)
forall x1 x2 : A, compose g f x1 = compose g f x2

从这个状态中,我尝试在h中应用H2,以证明f(x1)= f( x2)。我尝试了应用策略以及专业策略,但它们都没有起作用。

这是我关注的实际证明:

”在此处输入图像描述

编辑: 非常感谢您的帮助!该代码现在可以工作:

Theorem compose_injective {A B C} (g: B -> C) (f: A -> B) :
  injective f /\ injective g -> injective (compose g f).
Proof.
  intros.
  destruct H as (H1,H2).
  unfold injective.
  intros.
  unfold injective in H2.
  apply H2 in H.
  unfold injective in H1.
  apply H1 in H.
  exact H.

I am very new to Coq and I'm trying to prove that if two functions are injectives, the composition of theses two functions is also injective.
Here is my code:

Definition compose {A B C} (g: B -> C) (f: A -> B) :=
  fun x : A => g (f x).

Definition injective {A B} (f: A -> B) :=
  forall x1 x2, f x1 = f x2 -> x1 = x2.

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

Theorem example {A B C} (g: B -> C) (f: A -> B) :
  injective f /\ injective g -> injective (compose g f).
Proof.
  intros.
  destruct H as (H1,H2).
  cut (forall x1 x2: A, (compose g f) x1 = (compose g f) x2).
  intros.
  unfold compose in H.
  unfold injective in H2.

The result is:

2 goals
A : Type
B : Type
C : Type
g : B -> C
f : A -> B
H1 : injective f
H2 : forall x1 x2 : B, g x1 = g x2 -> x1 = x2
H : forall x1 x2 : A, g (f x1) = g (f x2)
______________________________________(1/2)
injective (compose g f)
______________________________________(2/2)
forall x1 x2 : A, compose g f x1 = compose g f x2

From this state, I am trying to apply H2 in H in order to prove that f(x1)=f(x2). I have tried the apply tactic as well as the specialized tactic but none of them worked.

Here is the actual proof I am following :

enter image description here

EDIT:
Thank you very much for you help! This code works now :

Theorem compose_injective {A B C} (g: B -> C) (f: A -> B) :
  injective f /\ injective g -> injective (compose g f).
Proof.
  intros.
  destruct H as (H1,H2).
  unfold injective.
  intros.
  unfold injective in H2.
  apply H2 in H.
  unfold injective in H1.
  apply H1 in H.
  exact H.

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

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

发布评论

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

评论(2

哀由 2025-02-04 20:29:48

而不是剪切,请使用展开的注入式。显示假设compose gfx = compose gf x'

Instead of cut, use unfold injective. to reveal the hypothesis compose g f x = compose g f x'.

若沐 2025-02-04 20:29:48

在H中应用H2说您缺少x1x2。首先,x1x2 展开 in Injective 在您的目标中,并使用intros代码>。然后,您可以在H1中应用H2 (带有适当的参数)

apply H2 in H says you're missing an x1 and x2. First get yourself an x1 and x2 by unfolding injective in your goal and using intros. Then you can apply H2 (with appropriate parameters) in H1.

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