如何在coq中证明(f1+;f1=f2+;f2->;f1=f2)

如何在coq中证明(f1+;f1=f2+;f2->;f1=f2),coq,Coq,我是Coq的新手。我想证明一个引理: Require Import Reals. Open Scope R_scope. Definition fadd (f g:R->R) := fun x => f x + g x. Notation "f +f g" := (fadd f g) (at level 61, left associativity). (** f+f = g+g->f=g **) Lemma fun_add: forall f g, f +

我是Coq的新手。我想证明一个引理:

Require Import Reals.
Open Scope R_scope.
Definition fadd (f g:R->R) := fun x => f x + g x.
Notation "f +f g" := (fadd f g) (at level 61, left associativity).
(** f+f = g+g->f=g **)
Lemma fun_add: forall f g, f +f f  = g  +f g  -> f = g.
但是我不知道怎么做,我已经证明了带环的plus-comm引理

Lemma fun_add_comm : forall f g, f +f g = g +f f.
Proof.
intros.
apply functional_extensionality.
intros.
unfold fadd.
ring.
Qed.

但是它在这方面似乎不起作用。

如果你想用CoQ做数学,我建议你看看SSReflect战术语言,以及数学组件库(和可用的书籍)

下面是使用此框架的引理的证明(可能有更简单的版本)


请注意,此处用于函数相等的
=1
相等对应于函数扩展性(如果两个函数对任何参数的应用相等,则两个函数相等)。

使用的策略库附带一个自动验证扩展,称为
lra
。你可以从中受益

Require Import FunctionalExtensionality.
Require Import Reals Lra.
Definition fadd (f g:R->R) := fun x => f x + g x.
Notation "f +f g" := (fadd f g) (at level 61, left associativity).

Lemma fun_add: forall f g, f +f f  = g  +f g  -> f = g.
Proof.
intros f g adds.
apply functional_extensionality.
intros x.
assert (adds_on_x : (f +f f) x = (g +f g) x).
   rewrite adds.
   reflexivity.
unfold fadd in adds_on_x.
lra.
Qed.
这不容易辨认
fx+fx
实际上是
(f+ff)x
,因此您需要通过在
assert
命令的语句中显式表示来帮助系统。

=1
对应于函数的逐点相等,函数可扩展性是一个公理,它说的是
f=1g->f=g
;我不够精确。您给出的示例不是自包含的,您应该添加
Require Import FunctionalExtensionality.
作为第一行:这将有助于问题的未来读者。
Require Import Reals Lra.

Notation "f =1 g" := (forall x, f x = g x) (at level 80).
Notation "f +' g" := (fun x => f x + g x)%R (at level 61).

Goal forall (f g : R -> R), f +' f =1 g +' g -> f =1 g.
  intros f g H x.
  pose proof (H x) as Hx.
  lra.
Qed.
Require Import Reals Lra.

Notation "f =1 g" := (forall x, f x = g x) (at level 80).
Notation "f +' g" := (fun x => f x + g x)%R (at level 61).

Goal forall (f g : R -> R), f +' f =1 g +' g -> f =1 g.
  intros f g H x.
  pose proof (H x) as Hx.
  lra.
Qed.