(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(* Definitions of the empty set, pair, union, intersection, comprehension  *)
(*  axiom and powerset, together with their properties                     *)
(* Useful types (actually top and bottom)   *)
Inductive Un : Set :=
void : Un.
Inductive F : Set :=.
(* The empty set  (vide = french for empty)   *)
Definition Vide : Ens := sup F (fun f : F => match f return Ens with
end).
(* The axioms of the empty set *)
unfold Vide in |- *; simpl in |- *; intros E H; cut False.
simple induction 1.
elim H; intros x; elim x.
Qed.
unfold Vide in |- *; simple induction E; simpl in |- *; intros A e H H0;
split.
intros; elim (H0 (e x)); auto with zfc.
exists x; auto with zfc.
simple induction y.
Qed.
(* Pair *)
Definition Paire : forall E E' : Ens, Ens.
intros.
apply (sup bool).
simple induction 1.
exact E.
exact E'.
Defined.
(* The pair construction is extentional *)
unfold Paire in |- *.
simpl in |- *.
intros; split.
simple induction x.
exists true; auto with zfc.
exists false; auto with zfc.
simple induction y; simpl in |- *.
exists true; auto with zfc.
exists false; auto with zfc.
Qed.
unfold Paire in |- *; simpl in |- *; intros; split.
simple induction x.
exists true; auto with zfc.
exists false; auto with zfc.
simple induction y.
exists true; auto with zfc.
exists false; auto with zfc.
Qed.
Hint Resolve Paire_sound_right Paire_sound_left: zfc.
(* The axioms of the pair *)
unfold Paire in |- *; simpl in |- *; exists true; simpl in |- *;
auto with zfc.
Qed.
unfold Paire in |- *; simpl in |- *; exists false; simpl in |- *;
auto with zfc.
Qed.
unfold Paire in |- *; simpl in |- *.
simple induction 1; intros b; elim b; simpl in |- *; auto with zfc.
Qed.
Hint Resolve IN_Paire_left IN_Paire_right Vide_est_vide: zfc.
(* The singleton set  *)
(* Note that we could define it directly using the base type Un *)
Definition Sing (E : Ens) := Paire E E.
(* The axioms  *)
unfold Sing in |- *; auto with zfc.
Qed.
unfold Sing in |- *; intros E E' H; elim (Paire_IN E' E' E);
auto with zfc.
Qed.
Hint Resolve IN_Sing IN_Sing_EQ: zfc.
unfold Sing in |- *; intros; apply EQ_tran with (Paire A A');
auto with zfc.
Qed.
Hint Resolve Sing_sound: zfc.
intros; cut (IN E1 (Sing E2)).
intros; auto with zfc.
apply IN_sound_right with (Sing E1); auto with zfc.
Qed.
Hint Resolve EQ_Sing_EQ: zfc.
(* We here need sigma types -- i.e. computational existentials *)
Inductive sig (A : Type) (P : A -> Prop) : Type :=
exist : forall x : A, P x -> sig A P.
(* The set obtained by the comprehension (or separation) axiom *)
Definition Comp : Ens -> (Ens -> Prop) -> Ens.
simple induction 1; intros A f fr P.
apply (sup (sig A (fun x => P (f x)))).
simple induction 1; intros x p; exact (f x).
Defined.
(* The comprehension/separation axioms *)

Theorem Comp_INC : forall (E : Ens) (P : Ens -> Prop), INC (Comp E P) E.