(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(***************************************************************************)
(* File: couples.v                                                         *)
(* auteur: alex@sysal.ibp.fr                                               *)
(* date: 19/10/95                                                          *)
(***************************************************************************)
Require Export axs_remplacement.
Definition couple (a b : E) := paire (singleton a) (paire a b).
(* Proof of lem_paire_prop2                                                *)
intros; unfold iff in |- *; split; intros.
elim (lem_paire_propertie a b a c); intros.
elim H0; intros; [ idtac | idtac | auto with zfc ]; elim H2; intros;
[ auto with zfc | rewrite <- H3; rewrite H4; reflexivity ].
rewrite H; reflexivity.
Qed.
(* End of proof of lem_paire_prop2                                         *)
(* Proof of lem_sing_eq_paire                                              *)
intros; unfold singleton in |- *; unfold iff in |- *; split; intros.
elim (lem_paire_propertie a a b c); intros.
elim H0; intros;
[ auto with zfc
| elim H2; intros; split; auto with zfc
| auto with zfc ].
elim H; intros; rewrite <- H0; rewrite <- H1; reflexivity.
Qed.
(* End of proof of lem_sing_eq_paire                                       *)
(* Proof of lem_couple_propertie                                           *)
unfold couple in |- *; intros.
unfold iff in |- *; split; intros.
elim
(lem_paire_propertie (singleton al) (paire al bl)
(singleton ar) (paire ar br)); intros.
clear H1; elim H0; clear H0; intros; [ idtac | idtac | auto with zfc ];
elim H0; clear H0; intros.
elim (lem_singleton_propertie al ar); intros.
generalize H1; clear H1; elim H2; clear H2; intros;
[ idtac | auto with zfc ].
elim (lem_paire_prop2 al bl br); intros.
split; [ reflexivity | auto with zfc ].
elim (lem_sing_eq_paire al ar br); intros.
elim (lem_sing_eq_paire ar al bl); intros.
cut (singleton ar = paire al bl); intros;
[ idtac | symmetry  in |- *; auto with zfc ].
elim H2; intros; [ idtac | auto with zfc ].
elim H4; intros; [ idtac | auto with zfc ].
rewrite <- H10; rewrite <- H7; rewrite <- H8; split; reflexivity.
elim H; clear H; intros.
rewrite H; rewrite H0; reflexivity.
Qed.
(* End of proof of lem_couple_propertie                                    *)
(* Proof of lem_couple_propertie_lr                                        *)
intros; elim (lem_couple_propertie al ar bl br); intros; exact (H0 H).
Qed.
(* End of proof of lem_couple_propertie_lr                                 *)
(* Proof of lem_couple_propertie_rl                                        *)
intros; elim (lem_couple_propertie al ar bl br); intros; exact (H1 H).
Qed.
(* End of proof of lem_couple_propertie_rl                                 *)
(***************************************************************************)
(* Produit cartesien de deux ensembles                                     *)
(***************************************************************************)
Definition cartesien (a b : E) :=
subset
(fun u : E =>
exists x : E, (exists y : E, In x a /\ In y b /\ u = couple x y))
(parties (parties (union a b))).
(* Proof of lem_cartesian_propertie                                        *)
intros; unfold cartesien in |- *.
elim
(axs_comprehension
(fun u : E =>
exists x0 : E, (exists y : E, In x0 a /\ In y b /\ u = couple x0 y))
(parties (parties (union a b))) x); intros.
unfold iff in |- *; split; intros.
elim H; clear H; clear H0; intros; [ idtac | auto with zfc ].
do 2 (elim H0; clear H0; intros); exists x0; exists x1; auto with zfc.
do 2 (elim H1; clear H1; intros); clear H; apply H0; clear H0.
split; [ idtac | exists x0; exists x1; auto with zfc ].
elim H1; clear H1; intros; elim H0; clear H0; intros.
elim (axs_parties (parties (union a b)) x); intros.
clear H2; apply H3; clear H3; intros.
elim (axs_parties (union a b) v3); intros.
clear H3; apply H4; clear H4; intros.
elim (lem_union_propertie a b v0); intros.
clear H4; apply H5; clear H5; intros.
unfold couple in H1.
elim (axs_paire (singleton x0) (paire x0 x1) v3); intros.
generalize H2; rewrite H1; intros.
clear H5; elim H4; clear H4; intros; [ idtac | idtac | auto with zfc ].
generalize H3; rewrite H4; intros.
elim (lem_in_singleton x0 v0); intros.
generalize H; clear H8; elim H7; clear H7; intros;
[ idtac | auto with zfc ]; left; auto with zfc.
generalize H3; rewrite H4; intros.
elim (axs_paire x0 x1 v0); intros.
clear H8; elim H7; clear H7; intros;
[ rewrite H7; left; auto with zfc
| rewrite H7; right; auto with zfc
| auto with zfc ].
Qed.
(* End of proof of lem_cartesian_propertie                                 *)

Lemma lem_cartesian_cons :
forall x y a b : E, In x a -> In y b -> In (couple x y) (cartesien a b).