(* 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)                    *)
(* A Type-theoretical axiom of choice gives us the collection axiom  *)
Definition collection :=
forall P : Ens -> Ens -> Prop,
(forall x x' y : Ens, EQ x x' -> P x y -> P x' y) ->
(forall E : Ens, EXType _ (P E)) ->
forall E : Ens,
EXType _
(fun A : Ens =>
forall x : Ens, IN x E -> EXType _ (fun y : Ens => IN y A /\ P x y)).
Definition choice :=
forall (A B : Type) (P : A -> B -> Prop),
(forall a : A, EXType _ (fun b : B => P a b)) ->
EXType _ (fun f : A -> B => forall a : A, P a (f a)).
unfold collection in |- *; intro; intros P comp G E.
cut (EXType _ (fun f : Ens -> Ens => forall B : Ens, P B (f B))).
simple induction 1; intros f pf.
elim E; intros A g hr; intros.
exists (sup A (fun a : A => f (g a))).
simpl in |- *; intros X i.
elim i; intros a ea.
exists (f (g a)).
split.
exists a; auto with zfc.
apply comp with (g a); auto with zfc.
unfold choice in H.
apply H; intros.
elim (G a); intros b hb; exists b; auto with zfc.
Qed.
(* If we also assume the excluded middle, we can derive         *)
(* the usual replacement schemata.                              *)
Definition functional (P : Ens -> Ens -> Prop) :=
forall x y y' : Ens, P x y -> P x y' -> EQ y y'.
Definition replacement :=
forall P : Ens -> Ens -> Prop,
functional P ->
(forall x y y' : Ens, EQ y y' -> P x y -> P x y') ->
(forall x x' y : Ens, EQ x x' -> P x y -> P x' y) ->
forall X : Ens,
EXType _
(fun Y : Ens =>
forall y : Ens,
(IN y Y -> EXType _ (fun x : Ens => IN x X /\ P x y)) /\
(EXType _ (fun x : Ens => IN x X /\ P x y) -> IN y Y)).

Theorem classical_Collection_Replacement :
(forall S : Prop, S \/ (S -> False)) -> collection -> replacement.