(* End of proof of lem_App_rev                                        *)

(***************************************************************************)
(***************************************************************************)
(* Composition d'application                                               *)
(***************************************************************************)
(***************************************************************************)
Definition comp (f g a b c : E) (Af : fun_sig f a b) 
  (Ag : fun_sig g b c) :=
  subset
    (fun c : E =>
     exists y : E, In (couple (first c) y) f /\ In (couple y (second c)) g)
    (cartesien a c).(***************************************************************************)
(* Il peut paraitre necessaire de reformuler la definition de la           *)
(* composition.                                                            *)
(***************************************************************************)
Definition comp2 (f g a b c : E) :=
  subset
    (fun x : E =>
     fun_sig f a b ->
     fun_sig g b c ->
     exists y : E, In (couple (first x) y) f /\ In (couple y (second x)) g)
    (cartesien a c).

(* Specifications: *)
Lemma lem_comp2_eq_comp : forall (f g a b c : E) (Af : fun_sig f a b) (Ag : fun_sig g b c), comp f g a b c Af Ag = comp2 f g a b c.
Lemma lem_comp_is_fun : forall (f g a b c : E) (Af : fun_sig f a b) (Ag : fun_sig g b c), fun_ (comp f g a b c Af Ag).
Lemma lem_comp_dom : forall (f g a b c : E) (Af : fun_sig f a b) (Ag : fun_sig g b c), dom (comp f g a b c Af Ag) = dom f.
Lemma lem_comp_img : forall (f g a b c : E) (Af : fun_sig f a b) (Ag : fun_sig g b c), inc (Img (comp f g a b c Af Ag)) (Img g).
Lemma lem_comp_make : forall (f g a b c x y z : E) (Af : fun_sig f a b) (Ag : fun_sig g b c), In (couple x y) f -> In (couple y z) g -> In (couple x z) (comp f g a b c Af Ag).
Lemma lem_comp_intermed : forall (f g a b c x z : E) (Af : fun_sig f a b) (Ag : fun_sig g b c), In (couple x z) (comp f g a b c Af Ag) -> exists y : E, In (couple x y) f /\ In (couple y z) g.