Require Import FunctionalExtensionality.
Require Export compatible.
About functions from E to F 
Note that Coquelicot has: U UniformSpace, then T->U UniformSpace,
   and similar for CompleteSpace 
Functions to a ModuleSpace are a ModuleSpace 
Section Fcts.
Context {
E : 
Type}.
Context {
F : 
ModuleSpace R_Ring}.
Definition fct_plus (
f:
E->
F) (
g:
E->
F) : (
E->
F) :=
  
fun x => 
plus (
f x) (
g x).
Definition fct_scal (
l:
R) (
f:
E->
F) : (
E->
F) :=
  
fun x => 
scal l (
f x).
Definition fct_opp (
f:
E->
F) : (
E -> 
F) :=
  
fun x => 
opp (
f x).
Definition fct_zero:
E->
F := 
fun _ => 
zero.
Lemma fct_plus_comm: 
forall (
f g:
E->
F), 
fct_plus f g = 
fct_plus g f.
Proof.
Lemma fct_plus_assoc:
  
forall (
f g h:
E->
F), 
fct_plus f (
fct_plus g h) = 
fct_plus (
fct_plus f g) 
h.
Proof.
Lemma fct_plus_zero_r: 
forall f:
E->
F, 
fct_plus f fct_zero = 
f.
Proof.
Lemma fct_plus_opp_r: 
forall f:
E->
F, 
fct_plus f (
fct_opp f) = 
fct_zero.
Proof.
Definition fct_AbelianGroup_mixin :=
  
AbelianGroup.Mixin (
E->
F) 
fct_plus fct_opp fct_zero fct_plus_comm
   fct_plus_assoc fct_plus_zero_r fct_plus_opp_r.
Canonical fct_AbelianGroup :=
  
AbelianGroup.Pack (
E->
F) (
fct_AbelianGroup_mixin) (
E->
F).
Lemma fct_scal_assoc: 
forall x y (
u:
E->
F),
   
fct_scal x (
fct_scal y u) = 
fct_scal (
mult x y) 
u.
Proof.
Lemma fct_scal_one: 
forall (
u:
E->
F), 
fct_scal one u = 
u.
Proof.
Lemma fct_scal_distr_l: 
forall x (
u v:
E->
F), 
fct_scal x (
plus u v) = 
fct_plus (
fct_scal x u) (
fct_scal x v).
Proof.
Lemma fct_scal_distr_r: 
forall (
x y:
R) (
u:
E->
F), 
fct_scal (
Rplus x y) 
u = 
fct_plus (
fct_scal x u) (
fct_scal y u).
Proof.
Definition fct_ModuleSpace_mixin :=
  
ModuleSpace.Mixin R_Ring fct_AbelianGroup fct_scal fct_scal_assoc
     fct_scal_one fct_scal_distr_l fct_scal_distr_r.
Canonical fct_ModuleSpace :=
  
ModuleSpace.Pack R_Ring (
E->
F)
   (
ModuleSpace.Class R_Ring (
E->
F) 
_ fct_ModuleSpace_mixin) (
E->
F).
End Fcts.
Linear Mapping 
Section SSG_linear_mapping.
Context {
E : 
ModuleSpace R_Ring}.
Context {
F : 
ModuleSpace R_Ring}.
Definition is_linear_mapping (
phi: 
E -> 
F) :=
  (
forall (
x y : 
E), 
phi (
plus x y) = 
plus (
phi x) (
phi y))
     /\ (
forall (
x : 
E) (
l:
R), 
phi (
scal l x) = 
scal l (
phi x)).
Theorem compatible_g_is_linear_mapping:
    
compatible_g is_linear_mapping.
Proof.
Lemma is_linear_mapping_zero: 
forall f,
   
is_linear_mapping f -> 
f zero = 
zero.
Proof.
Lemma is_linear_mapping_opp: 
forall f x,
   
is_linear_mapping f -> 
f (
opp x) = 
opp (
f x).
Proof.
Lemma is_linear_mapping_f_zero:
   
is_linear_mapping (
fun (
x:
E) => @
zero F).
Proof.
Lemma is_linear_mapping_f_opp: 
forall (
f:
E->
F),
    
is_linear_mapping f ->
      
is_linear_mapping (
opp f).
Proof.
intros f (
H1,
H2); 
split.
intros x y; 
unfold opp; 
simpl; 
unfold fct_opp.
rewrite H1.
apply opp_plus.
intros x l; 
unfold opp; 
simpl; 
unfold fct_opp.
rewrite H2.
now rewrite <- 
scal_opp_r.
Qed.
 
Lemma is_linear_mapping_f_plus: 
forall (
f g:
E->
F),
    
is_linear_mapping f -> 
is_linear_mapping g ->
      
is_linear_mapping (
plus f g).
Proof.
Lemma is_linear_mapping_f_scal: 
forall l, 
forall (
f:
E->
F),
    
is_linear_mapping f ->
      
is_linear_mapping (
scal l f).
Proof.
End SSG_linear_mapping.
Section SSG_bilinear_mapping.
Context {
E : 
ModuleSpace R_Ring}.
Context {
F : 
ModuleSpace R_Ring}.
Context {
G : 
ModuleSpace R_Ring}.
Definition is_bilinear_mapping (
phi: 
E -> 
F -> 
G) :=
  (
forall (
x:
E) (
y:
F) (
l:
R), 
phi (
scal l x) 
y = 
scal l (
phi x y)) /\
  (
forall (
x:
E) (
y:
F) (
l:
R), 
phi x (
scal l y) = 
scal l (
phi x y)) /\
  (
forall (
x y: 
E) (
z:
F), 
phi (
plus x y) 
z = 
plus (
phi x z) (
phi y z)) /\
  (
forall (
x:
E) (
y z : 
F), 
phi x (
plus y z) = 
plus (
phi x y) (
phi x z)).
Theorem compatible_g_is_bilinear_mapping:
    
compatible_g is_bilinear_mapping.
split.
intros f g (
Hf1,(
Hf2,(
Hf3,
Hf4))) (
Hg1,(
Hg2,(
Hg3,
Hg4))).
split.
intros x y l;
unfold plus; 
unfold opp; 
simpl;
unfold fct_plus, 
fct_opp;
unfold plus, 
opp; 
simpl;
   
unfold fct_plus, 
fct_opp;
rewrite Hf1,
Hg1;
rewrite <- 
scal_opp_r;
now rewrite scal_distr_l.
split.
intros x y l;
unfold plus; 
unfold opp; 
simpl;
unfold fct_plus, 
fct_opp;
unfold plus, 
opp; 
simpl;
   
unfold fct_plus, 
fct_opp;
rewrite Hf2,
Hg2;
rewrite <- 
scal_opp_r;
now rewrite scal_distr_l.
split.
intros x y z; 
unfold plus at 1 4 5; 
unfold opp;
simpl; 
unfold fct_plus, 
fct_opp;
  
unfold plus at 1 5 6;
unfold opp;
simpl;
unfold fct_plus, 
fct_opp;
rewrite Hf3,
Hg3;
  
rewrite opp_plus;
rewrite plus_assoc;
rewrite plus_assoc;
apply f_equal2;
trivial.
 
rewrite <- 
plus_assoc;
rewrite (
plus_comm (
f y z) (
opp (
g x z)));
now rewrite plus_assoc.
intros x y z; 
unfold plus at 1 4 5; 
unfold opp;
simpl; 
unfold fct_plus, 
fct_opp.
  
unfold plus at 1 4 5;
unfold opp;
simpl;
unfold fct_plus, 
fct_opp. 
rewrite Hf4,
Hg4;
  
rewrite opp_plus;
rewrite plus_assoc;
rewrite plus_assoc;
apply f_equal2;
trivial.
 
rewrite <- 
plus_assoc;
rewrite (
plus_comm (
f x z) (
opp (
g x y)));
now rewrite plus_assoc.
exists zero;
split.
unfold zero;
intros;
simpl;
unfold fct_zero; 
simpl;
unfold zero;
simpl;
unfold fct_zero;
  
now rewrite scal_zero_r.
split.
unfold zero;
intros;
simpl;
unfold fct_zero; 
simpl;
unfold zero;
simpl;
unfold fct_zero;
  
now rewrite scal_zero_r.
split.
unfold zero;
intros;
simpl;
unfold fct_zero; 
simpl;
unfold zero;
simpl;
unfold fct_zero;
  
now rewrite plus_zero_l.
unfold zero;
intros;
simpl;
unfold fct_zero; 
simpl;
unfold zero;
simpl;
unfold fct_zero;
  
now rewrite plus_zero_l.
Qed.