(* 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)                    *)
(************************************************************************)
(*                      Zermolo Set Theory                              *)
(*                                                                      *)
(*                        Benjamin Werner                               *)
(************************************************************************)
(* This is an encoding of usual Set Theory, simillar to Peter Aczel's work *)
(* in the early 80's. The main difference is that the propositions here    *)
(* live in the impredicative world of "Prop". Thus, priority is given to   *)
(* expressivity against constructivity.                                    *)
(* Since the definition of Sets is the same for both approaches, I added   *)
(* most  of Aczel's encoding of CZF at the end of the file. Many           *)
(* definitions are common to both aproaches.                               *)
Set Asymmetric Patterns.
(* The type representing sets  (Ensemble = french for set) *)
Inductive Ens : Type :=
sup : forall A : Type, (A -> Ens) -> Ens.
(* Existential quantification *)
Inductive EXType (P : Type) (Q : P -> Prop) : Prop :=
EXTypei : forall x : P, Q x -> EXType P Q.
(* Cartesian product in Type *)
Inductive prod_t (A B : Type) : Type :=
pair_t : A -> B -> prod_t A B.
(* Existential on the Type level *)
Inductive depprod (A : Type) (P : A -> Type) : Type :=
dep_i : forall x : A, P x -> depprod A P.
(* Recursive Definition of the extentional equality on sets *)
Definition EQ : Ens -> Ens -> Prop.
simple induction 1; intros A f eq1.
simple induction 1; intros B g eq2.
apply and.
exact (forall x : A, EXType _ (fun y : B => eq1 x (g y))).
exact (forall y : B, EXType _ (fun x : A => eq1 x (g y))).
Defined.
(* Membership on sets *)
Definition IN (E1 E2 : Ens) : Prop :=
match E2 with
| sup A f => EXType _ (fun y : A => EQ E1 (f y))
end.
(* INCLUSION *)
Definition INC : Ens -> Ens -> Prop.
intros E1 E2.
exact (forall E : Ens, IN E E1 -> IN E E2).
Defined.
(* EQ is an equivalence relation  *)

Theorem EQ_refl : forall E : Ens, EQ E E.