(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(***************************************************************************)
(* File: applications.v                                                    *)
(* auteur: alex@sysal.ibp.fr                                               *)
(* date: 19/10/95                                                          *)
(***************************************************************************)
Require Export couples.
(***************************************************************************)
(***************************************************************************)
(* Relations n-aires                                                       *)
(***************************************************************************)
(***************************************************************************)
Definition n_aire (n : nat) (a : E) (F : E -> Prop) :=
subset F (cart_power n a).
(* Pas de reciproque (dixit pagano pb des ensembles non decidables)        *)
(* Proof of lem_subset                                                     *)
intros; elim (axs_comprehension F b y); intros.
generalize H1; rewrite <- H; clear H H1 H2; intros.
elim H1; intros; auto with zfc.
Qed.
(* End of proof of lem_subset                                              *)
(***************************************************************************)
(***************************************************************************)
(* applications                                                            *)
(***************************************************************************)
(***************************************************************************)
Definition fun_ (f : E) :=
(exists a : E, (exists b : E, inc f (cartesien a b))) /\
(forall x y z : E, In (couple x y) f -> In (couple x z) f -> y = z).
(***************************************************************************)
(* Domaine d'une application                                               *)
(***************************************************************************)
Definition dom (f : E) :=
subset (fun v0 : E => fun_ f -> exists v1 : E, In (couple v0 v1) f)
(reunion (reunion f)).
(***************************************************************************)
(* Image d'une application                                                 *)
(***************************************************************************)
Definition Img (f : E) :=
subset (fun v1 : E => fun_ f -> exists v0 : E, In (couple v0 v1) f)
(reunion (reunion f)).
(***************************************************************************)
(* f est une application de a vers b                                       *)
(***************************************************************************)
Definition fun_sig (f a b : E) := fun_ f /\ dom f = a /\ inc (Img f) b.
(* Proof of lem_fun_sig_is_fun                                             *)
unfold fun_sig in |- *; intros.
elim H; clear H; intros; auto with zfc.
Qed.
(* End of proof of lem_fun_sig_is_fun                                      *)
(* Proof of lem_fun_sig_dom                                                *)
intros; elim H; clear H; intros; elim H0; clear H0; intros; auto with zfc.
Qed.
(* End of proof of lem_fun_sig_dom                                         *)
(* Proof of lem_fun_sig_img                                                *)
intros; elim H; clear H; intros; elim H0; clear H0; intros; auto with zfc.
Qed.
(* End of proof of lem_fun_sig_img                                         *)
(***************************************************************************)
(* f est une application surjective de a vers b                            *)
(***************************************************************************)
Definition fun_surj (f a b : E) := fun_ f /\ dom f = a /\ Img f = b.
(***************************************************************************)
(* f est une application injective                                         *)
(***************************************************************************)
Definition fun_inj (f a b : E) :=
fun_ f /\
dom f = a /\
inc (Img f) b /\
(forall b : E, In b (Img f) -> exUniq _ (fun a : E => In (couple a b) f)).
(***************************************************************************)
(* f est une bijection                                                     *)
(***************************************************************************)
Definition fun_bij (f a b : E) :=
fun_ f /\
dom f = a /\
Img f = b /\
(forall b : E, In b (Img f) -> exUniq _ (fun a : E => In (couple a b) f)).
(* Proof of lem_surj_to_sig                                                *)
unfold fun_surj in |- *; unfold fun_sig in |- *; intros.
elim H; clear H; intros; elim H0; clear H0; intros.
split;
[ auto with zfc
| split; [ auto with zfc | unfold inc in |- *; intros ] ].
generalize H2; rewrite H1; tauto.
Qed.
(* End of proof of lem_surj_to_sig                                         *)
(* Proof of lem_inj_to_sig                                                 *)
unfold fun_inj in |- *; unfold fun_sig in |- *; intros.
elim H; clear H; intros; elim H0; clear H0; intros; elim H1; clear H1; intros.
split; [ auto with zfc | split; auto with zfc ].
Qed.
(* End of proof of lem_inj_to_sig                                          *)
(* Proof of lem_bij_to_sig                                                 *)
unfold fun_bij in |- *; unfold fun_sig in |- *; intros.
elim H; clear H; intros; elim H0; clear H0; intros; elim H1; clear H1; intros.
split;
[ auto with zfc
| split; [ auto with zfc | unfold inc in |- *; intros ] ].
rewrite <- H1; auto with zfc.
Qed.
(* End of proof of lem_bij_to_sig                                          *)
(* Proof of lem_bij_is_inj                                                 *)
unfold fun_bij, fun_inj in |- *; intros.
elim H; clear H; intros; elim H0; clear H0; intros; elim H1; clear H1; intros.
split;
[ auto with zfc
| split;
[ auto with zfc
| split;
[ unfold inc in |- *; intros; rewrite <- H1; auto with zfc
| auto with zfc ] ] ].
Qed.
(* End of proof of lem_bij_is_inj                                          *)
(* Proof of lem_bij_is_inj                                                 *)
unfold fun_bij, fun_surj in |- *; intros.
elim H; clear H; intros; elim H0; clear H0; intros; elim H1; clear H1; intros.
split; [ auto with zfc | split; auto with zfc ].
Qed.
(* End of proof of lem_bij_is_inj                                          *)
(* Proof of lem_inj_surj_is_bij                                            *)
unfold fun_surj, fun_inj, fun_bij in |- *; intros.
elim H; clear H; intros; clear H; elim H1; clear H1; intros; clear H.
elim H0; clear H0; intros; elim H0; clear H0; intros; elim H2; clear H2;
intros.
split;
[ auto with zfc
| split; [ auto with zfc | split; auto with zfc ] ].
Qed.
(* End of proof of lem_inj_surj_is_bij                                     *)
(***************************************************************************)
(***************************************************************************)
(* L'application Vide                                                      *)
(***************************************************************************)
(***************************************************************************)
(* Proof of lem_vide_application                                           *)
unfold fun_ in |- *; split;
[ exists Vide; exists Vide; exact (lem_vide_is_inc (cartesien Vide Vide))
| intros ].
unfold Vide in H; elim (lem_vide_propertie (couple x y) var_vide);
auto with zfc.
Qed.
(* End of proof of lem_vide_application                                    *)
(* Proof of lem_dom_vide                                                   *)
apply axs_extensionnalite; intros; unfold iff in |- *; split; intros;
unfold dom in H.
elim
(axs_comprehension
(fun v0 : E => fun_ Vide -> exists v1 : E, In (couple v0 v1) Vide)
(reunion (reunion Vide)) v2); intros; generalize (H0 H);
clear H H0 H1; intros.
generalize H; rewrite lem_reunion_vide; rewrite lem_reunion_vide; tauto.
elim (lem_vide_propertie v2 var_vide); auto with zfc.
Qed.
(* End of proof of  lem_dom_vide                                           *)

(***************************************************************************)
(* L'image de l'application Vide est Vide                                  *)
(***************************************************************************)
Lemma lem_img_vide : Img Vide = Vide.