summaryrefslogtreecommitdiff
path: root/theories/Logic/ChoiceFacts.v
diff options
context:
space:
mode:
Diffstat (limited to 'theories/Logic/ChoiceFacts.v')
-rw-r--r--theories/Logic/ChoiceFacts.v710
1 files changed, 583 insertions, 127 deletions
diff --git a/theories/Logic/ChoiceFacts.v b/theories/Logic/ChoiceFacts.v
index 1420a000..238ac7df 100644
--- a/theories/Logic/ChoiceFacts.v
+++ b/theories/Logic/ChoiceFacts.v
@@ -1,93 +1,35 @@
-(* -*- coding: utf-8 -*- *)
(************************************************************************)
-(* v * The Coq Proof Assistant / The Coq Development Team *)
-(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *)
+(* * The Coq Proof Assistant / The Coq Development Team *)
+(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
+(* <O___,, * (see CREDITS file for the list of authors) *)
(* \VV/ **************************************************************)
-(* // * This file is distributed under the terms of the *)
-(* * GNU Lesser General Public License Version 2.1 *)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(* * (see LICENSE file for the text of the license) *)
+(************************************************************************)
(************************************************************************)
(** Some facts and definitions concerning choice and description in
- intuitionistic logic.
-
-We investigate the relations between the following choice and
-description principles
-
-- AC_rel = relational form of the (non extensional) axiom of choice
- (a "set-theoretic" axiom of choice)
-- AC_fun = functional form of the (non extensional) axiom of choice
- (a "type-theoretic" axiom of choice)
-- DC_fun = functional form of the dependent axiom of choice
-- ACw_fun = functional form of the countable axiom of choice
-- AC! = functional relation reification
- (known as axiom of unique choice in topos theory,
- sometimes called principle of definite description in
- the context of constructive type theory)
-
-- GAC_rel = guarded relational form of the (non extensional) axiom of choice
-- GAC_fun = guarded functional form of the (non extensional) axiom of choice
-- GAC! = guarded functional relation reification
-
-- OAC_rel = "omniscient" relational form of the (non extensional) axiom of choice
-- OAC_fun = "omniscient" functional form of the (non extensional) axiom of choice
- (called AC* in Bell [[Bell]])
-- OAC!
-
-- ID_iota = intuitionistic definite description
-- ID_epsilon = intuitionistic indefinite description
-
-- D_iota = (weakly classical) definite description principle
-- D_epsilon = (weakly classical) indefinite description principle
-
-- PI = proof irrelevance
-- IGP = independence of general premises
- (an unconstrained generalisation of the constructive principle of
- independence of premises)
-- Drinker = drinker's paradox (small form)
- (called Ex in Bell [[Bell]])
-
-We let also
-
-- IPL_2 = 2nd-order impredicative minimal predicate logic (with ex. quant.)
-- IPL^2 = 2nd-order functional minimal predicate logic (with ex. quant.)
-- IPL_2^2 = 2nd-order impredicative, 2nd-order functional minimal pred. logic (with ex. quant.)
-
-with no prerequisite on the non-emptiness of domains
-
-Table of contents
-
-1. Definitions
-
-2. IPL_2^2 |- AC_rel + AC! = AC_fun
-
-3.1. typed IPL_2 + Sigma-types + PI |- AC_rel = GAC_rel and IPL_2 |- AC_rel + IGP -> GAC_rel and IPL_2 |- GAC_rel = OAC_rel
-
-3.2. IPL^2 |- AC_fun + IGP = GAC_fun = OAC_fun = AC_fun + Drinker
-
-3.3. D_iota -> ID_iota and D_epsilon <-> ID_epsilon + Drinker
-
-4. Derivability of choice for decidable relations with well-ordered codomain
-
-5. Equivalence of choices on dependent or non dependent functional types
-
-6. Non contradiction of constructive descriptions wrt functional choices
-
-7. Definite description transports classical logic to the computational world
-
-8. Choice -> Dependent choice -> Countable choice
-
-References:
-
+ intuitionistic logic. *)
+(** * References: *)
+(**
[[Bell]] John L. Bell, Choice principles in intuitionistic set theory,
unpublished.
[[Bell93]] John L. Bell, Hilbert's Epsilon Operator in Intuitionistic
Type Theories, Mathematical Logic Quarterly, volume 39, 1993.
+[[Carlström04]] Jesper Carlström, EM + Ext_ + AC_int is equivalent to
+AC_ext, Mathematical Logic Quaterly, vol 50(3), pp 236-240, 2004.
+
[[Carlström05]] Jesper Carlström, Interpreting descriptions in
intentional type theory, Journal of Symbolic Logic 70(2):488-514, 2005.
+
+[[Werner97]] Benjamin Werner, Sets in Types, Types in Sets, TACS, 1997.
*)
+Require Import RelationClasses Logic.
+
Set Implicit Arguments.
Local Unset Intuition Negation Unfolding.
@@ -108,59 +50,139 @@ Variables A B :Type.
Variable P:A->Prop.
-Variable R:A->B->Prop.
-
(** ** Constructive choice and description *)
-(** AC_rel *)
+(** AC_rel = relational form of the (non extensional) axiom of choice
+ (a "set-theoretic" axiom of choice) *)
Definition RelationalChoice_on :=
forall R:A->B->Prop,
(forall x : A, exists y : B, R x y) ->
(exists R' : A->B->Prop, subrelation R' R /\ forall x, exists! y, R' x y).
-(** AC_fun *)
+(** AC_fun = functional form of the (non extensional) axiom of choice
+ (a "type-theoretic" axiom of choice) *)
+
+(* Note: This is called Type-Theoretic Description Axiom (TTDA) in
+ [[Werner97]] (using a non-standard meaning of "description"). This
+ is called intensional axiom of choice (AC_int) in [[Carlström04]] *)
+
+Definition FunctionalChoice_on_rel (R:A->B->Prop) :=
+ (forall x:A, exists y : B, R x y) ->
+ exists f : A -> B, (forall x:A, R x (f x)).
Definition FunctionalChoice_on :=
forall R:A->B->Prop,
(forall x : A, exists y : B, R x y) ->
(exists f : A->B, forall x : A, R x (f x)).
-(** DC_fun *)
+(** AC_fun_dep = functional form of the (non extensional) axiom of
+ choice, with dependent functions *)
+Definition DependentFunctionalChoice_on (A:Type) (B:A -> Type) :=
+ forall R:forall x:A, B x -> Prop,
+ (forall x:A, exists y : B x, R x y) ->
+ (exists f : (forall x:A, B x), forall x:A, R x (f x)).
+
+(** AC_trunc = axiom of choice for propositional truncations
+ (truncation and quantification commute) *)
+Definition InhabitedForallCommute_on (A : Type) (B : A -> Type) :=
+ (forall x, inhabited (B x)) -> inhabited (forall x, B x).
+
+(** DC_fun = functional form of the dependent axiom of choice *)
Definition FunctionalDependentChoice_on :=
forall (R:A->A->Prop),
(forall x, exists y, R x y) -> forall x0,
(exists f : nat -> A, f 0 = x0 /\ forall n, R (f n) (f (S n))).
-(** ACw_fun *)
+(** ACw_fun = functional form of the countable axiom of choice *)
Definition FunctionalCountableChoice_on :=
forall (R:nat->A->Prop),
(forall n, exists y, R n y) ->
(exists f : nat -> A, forall n, R n (f n)).
-(** AC! or Functional Relation Reification (known as Axiom of Unique Choice
- in topos theory; also called principle of definite description *)
+(** AC! = functional relation reification
+ (known as axiom of unique choice in topos theory,
+ sometimes called principle of definite description in
+ the context of constructive type theory, sometimes
+ called axiom of no choice) *)
Definition FunctionalRelReification_on :=
forall R:A->B->Prop,
(forall x : A, exists! y : B, R x y) ->
(exists f : A->B, forall x : A, R x (f x)).
-(** ID_epsilon (constructive version of indefinite description;
- combined with proof-irrelevance, it may be connected to
- Carlström's type theory with a constructive indefinite description
- operator) *)
+(** AC_dep! = functional relation reification, with dependent functions
+ see AC! *)
+Definition DependentFunctionalRelReification_on (A:Type) (B:A -> Type) :=
+ forall (R:forall x:A, B x -> Prop),
+ (forall x:A, exists! y : B x, R x y) ->
+ (exists f : (forall x:A, B x), forall x:A, R x (f x)).
+
+(** AC_fun_repr = functional choice of a representative in an equivalence class *)
+
+(* Note: This is called Type-Theoretic Choice Axiom (TTCA) in
+ [[Werner97]] (by reference to the extensional set-theoretic
+ formulation of choice); Note also a typo in its intended
+ formulation in [[Werner97]]. *)
+
+Definition RepresentativeFunctionalChoice_on :=
+ forall R:A->A->Prop,
+ (Equivalence R) ->
+ (exists f : A->A, forall x : A, (R x (f x)) /\ forall x', R x x' -> f x = f x').
+
+(** AC_fun_setoid = functional form of the (so-called extensional) axiom of
+ choice from setoids *)
+
+Definition SetoidFunctionalChoice_on :=
+ forall R : A -> A -> Prop,
+ forall T : A -> B -> Prop,
+ Equivalence R ->
+ (forall x x' y, R x x' -> T x y -> T x' y) ->
+ (forall x, exists y, T x y) ->
+ exists f : A -> B, forall x : A, T x (f x) /\ (forall x' : A, R x x' -> f x = f x').
+
+(** AC_fun_setoid_gen = functional form of the general form of the (so-called
+ extensional) axiom of choice over setoids *)
+
+(* Note: This is called extensional axiom of choice (AC_ext) in
+ [[Carlström04]]. *)
+
+Definition GeneralizedSetoidFunctionalChoice_on :=
+ forall R : A -> A -> Prop,
+ forall S : B -> B -> Prop,
+ forall T : A -> B -> Prop,
+ Equivalence R ->
+ Equivalence S ->
+ (forall x x' y y', R x x' -> S y y' -> T x y -> T x' y') ->
+ (forall x, exists y, T x y) ->
+ exists f : A -> B,
+ forall x : A, T x (f x) /\ (forall x' : A, R x x' -> S (f x) (f x')).
+
+(** AC_fun_setoid_simple = functional form of the (so-called extensional) axiom of
+ choice from setoids on locally compatible relations *)
+
+Definition SimpleSetoidFunctionalChoice_on A B :=
+ forall R : A -> A -> Prop,
+ forall T : A -> B -> Prop,
+ Equivalence R ->
+ (forall x, exists y, forall x', R x x' -> T x' y) ->
+ exists f : A -> B, forall x : A, T x (f x) /\ (forall x' : A, R x x' -> f x = f x').
+
+(** ID_epsilon = constructive version of indefinite description;
+ combined with proof-irrelevance, it may be connected to
+ Carlström's type theory with a constructive indefinite description
+ operator *)
Definition ConstructiveIndefiniteDescription_on :=
forall P:A->Prop,
(exists x, P x) -> { x:A | P x }.
-(** ID_iota (constructive version of definite description; combined
- with proof-irrelevance, it may be connected to Carlström's and
- Stenlund's type theory with a constructive definite description
- operator) *)
+(** ID_iota = constructive version of definite description;
+ combined with proof-irrelevance, it may be connected to
+ Carlström's and Stenlund's type theory with a
+ constructive definite description operator) *)
Definition ConstructiveDefiniteDescription_on :=
forall P:A->Prop,
@@ -168,7 +190,7 @@ Definition ConstructiveDefiniteDescription_on :=
(** ** Weakly classical choice and description *)
-(** GAC_rel *)
+(** GAC_rel = guarded relational form of the (non extensional) axiom of choice *)
Definition GuardedRelationalChoice_on :=
forall P : A->Prop, forall R : A->B->Prop,
@@ -176,7 +198,7 @@ Definition GuardedRelationalChoice_on :=
(exists R' : A->B->Prop,
subrelation R' R /\ forall x, P x -> exists! y, R' x y).
-(** GAC_fun *)
+(** GAC_fun = guarded functional form of the (non extensional) axiom of choice *)
Definition GuardedFunctionalChoice_on :=
forall P : A->Prop, forall R : A->B->Prop,
@@ -184,7 +206,7 @@ Definition GuardedFunctionalChoice_on :=
(forall x : A, P x -> exists y : B, R x y) ->
(exists f : A->B, forall x, P x -> R x (f x)).
-(** GFR_fun *)
+(** GAC! = guarded functional relation reification *)
Definition GuardedFunctionalRelReification_on :=
forall P : A->Prop, forall R : A->B->Prop,
@@ -192,27 +214,28 @@ Definition GuardedFunctionalRelReification_on :=
(forall x : A, P x -> exists! y : B, R x y) ->
(exists f : A->B, forall x : A, P x -> R x (f x)).
-(** OAC_rel *)
+(** OAC_rel = "omniscient" relational form of the (non extensional) axiom of choice *)
Definition OmniscientRelationalChoice_on :=
forall R : A->B->Prop,
exists R' : A->B->Prop,
subrelation R' R /\ forall x : A, (exists y : B, R x y) -> exists! y, R' x y.
-(** OAC_fun *)
+(** OAC_fun = "omniscient" functional form of the (non extensional) axiom of choice
+ (called AC* in Bell [[Bell]]) *)
Definition OmniscientFunctionalChoice_on :=
forall R : A->B->Prop,
inhabited B ->
exists f : A->B, forall x : A, (exists y : B, R x y) -> R x (f x).
-(** D_epsilon *)
+(** D_epsilon = (weakly classical) indefinite description principle *)
Definition EpsilonStatement_on :=
forall P:A->Prop,
inhabited A -> { x:A | (exists x, P x) -> P x }.
-(** D_iota *)
+(** D_iota = (weakly classical) definite description principle *)
Definition IotaStatement_on :=
forall P:A->Prop,
@@ -226,14 +249,28 @@ Notation RelationalChoice :=
(forall A B : Type, RelationalChoice_on A B).
Notation FunctionalChoice :=
(forall A B : Type, FunctionalChoice_on A B).
-Definition FunctionalDependentChoice :=
+Notation DependentFunctionalChoice :=
+ (forall A (B:A->Type), DependentFunctionalChoice_on B).
+Notation InhabitedForallCommute :=
+ (forall A (B : A -> Type), InhabitedForallCommute_on B).
+Notation FunctionalDependentChoice :=
(forall A : Type, FunctionalDependentChoice_on A).
-Definition FunctionalCountableChoice :=
+Notation FunctionalCountableChoice :=
(forall A : Type, FunctionalCountableChoice_on A).
Notation FunctionalChoiceOnInhabitedSet :=
(forall A B : Type, inhabited B -> FunctionalChoice_on A B).
Notation FunctionalRelReification :=
(forall A B : Type, FunctionalRelReification_on A B).
+Notation DependentFunctionalRelReification :=
+ (forall A (B:A->Type), DependentFunctionalRelReification_on B).
+Notation RepresentativeFunctionalChoice :=
+ (forall A : Type, RepresentativeFunctionalChoice_on A).
+Notation SetoidFunctionalChoice :=
+ (forall A B: Type, SetoidFunctionalChoice_on A B).
+Notation GeneralizedSetoidFunctionalChoice :=
+ (forall A B : Type, GeneralizedSetoidFunctionalChoice_on A B).
+Notation SimpleSetoidFunctionalChoice :=
+ (forall A B : Type, SimpleSetoidFunctionalChoice_on A B).
Notation GuardedRelationalChoice :=
(forall A B : Type, GuardedRelationalChoice_on A B).
@@ -259,18 +296,87 @@ Notation EpsilonStatement :=
(** Subclassical schemes *)
+(** PI = proof irrelevance *)
Definition ProofIrrelevance :=
forall (A:Prop) (a1 a2:A), a1 = a2.
+(** IGP = independence of general premises
+ (an unconstrained generalisation of the constructive principle of
+ independence of premises) *)
Definition IndependenceOfGeneralPremises :=
forall (A:Type) (P:A -> Prop) (Q:Prop),
inhabited A ->
(Q -> exists x, P x) -> exists x, Q -> P x.
+(** Drinker = drinker's paradox (small form)
+ (called Ex in Bell [[Bell]]) *)
Definition SmallDrinker'sParadox :=
forall (A:Type) (P:A -> Prop), inhabited A ->
exists x, (exists x, P x) -> P x.
+(** EM = excluded-middle *)
+Definition ExcludedMiddle :=
+ forall P:Prop, P \/ ~ P.
+
+(** Extensional schemes *)
+
+(** Ext_prop_repr = choice of a representative among extensional propositions *)
+Local Notation ExtensionalPropositionRepresentative :=
+ (forall (A:Type),
+ exists h : Prop -> Prop,
+ forall P : Prop, (P <-> h P) /\ forall Q, (P <-> Q) -> h P = h Q).
+
+(** Ext_pred_repr = choice of a representative among extensional predicates *)
+Local Notation ExtensionalPredicateRepresentative :=
+ (forall (A:Type),
+ exists h : (A->Prop) -> (A->Prop),
+ forall (P : A -> Prop), (forall x, P x <-> h P x) /\ forall Q, (forall x, P x <-> Q x) -> h P = h Q).
+
+(** Ext_fun_repr = choice of a representative among extensional functions *)
+Local Notation ExtensionalFunctionRepresentative :=
+ (forall (A B:Type),
+ exists h : (A->B) -> (A->B),
+ forall (f : A -> B), (forall x, f x = h f x) /\ forall g, (forall x, f x = g x) -> h f = h g).
+
+(** We let also
+
+- IPL_2 = 2nd-order impredicative minimal predicate logic (with ex. quant.)
+- IPL^2 = 2nd-order functional minimal predicate logic (with ex. quant.)
+- IPL_2^2 = 2nd-order impredicative, 2nd-order functional minimal pred. logic (with ex. quant.)
+
+with no prerequisite on the non-emptiness of domains
+*)
+
+(**********************************************************************)
+(** * Table of contents *)
+
+(* This is very fragile. *)
+(**
+1. Definitions
+
+2. IPL_2^2 |- AC_rel + AC! = AC_fun
+
+3.1. typed IPL_2 + Sigma-types + PI |- AC_rel = GAC_rel and IPL_2 |- AC_rel + IGP -> GAC_rel and IPL_2 |- GAC_rel = OAC_rel
+
+3.2. IPL^2 |- AC_fun + IGP = GAC_fun = OAC_fun = AC_fun + Drinker
+
+3.3. D_iota -> ID_iota and D_epsilon <-> ID_epsilon + Drinker
+
+4. Derivability of choice for decidable relations with well-ordered codomain
+
+5. AC_fun = AC_fun_dep = AC_trunc
+
+6. Non contradiction of constructive descriptions wrt functional choices
+
+7. Definite description transports classical logic to the computational world
+
+8. Choice -> Dependent choice -> Countable choice
+
+9.1. AC_fun_setoid = AC_fun + Ext_fun_repr + EM
+
+9.2. AC_fun_setoid = AC_fun + Ext_pred_repr + PI
+ *)
+
(**********************************************************************)
(** * AC_rel + AC! = AC_fun
@@ -284,7 +390,7 @@ Definition SmallDrinker'sParadox :=
relational formulation) without known inconsistency with classical logic,
though functional relation reification conflicts with classical logic *)
-Lemma description_rel_choice_imp_funct_choice :
+Lemma functional_rel_reification_and_rel_choice_imp_fun_choice :
forall A B : Type,
FunctionalRelReification_on A B -> RelationalChoice_on A B -> FunctionalChoice_on A B.
Proof.
@@ -298,7 +404,7 @@ Proof.
apply HR'R; assumption.
Qed.
-Lemma funct_choice_imp_rel_choice :
+Lemma fun_choice_imp_rel_choice :
forall A B : Type, FunctionalChoice_on A B -> RelationalChoice_on A B.
Proof.
intros A B FunCh R H.
@@ -311,7 +417,7 @@ Proof.
trivial.
Qed.
-Lemma funct_choice_imp_description :
+Lemma fun_choice_imp_functional_rel_reification :
forall A B : Type, FunctionalChoice_on A B -> FunctionalRelReification_on A B.
Proof.
intros A B FunCh R H.
@@ -324,15 +430,15 @@ Proof.
exists f; exact H0.
Qed.
-Corollary FunChoice_Equiv_RelChoice_and_ParamDefinDescr :
+Corollary fun_choice_iff_rel_choice_and_functional_rel_reification :
forall A B : Type, FunctionalChoice_on A B <->
RelationalChoice_on A B /\ FunctionalRelReification_on A B.
Proof.
intros A B. split.
intro H; split;
- [ exact (funct_choice_imp_rel_choice H)
- | exact (funct_choice_imp_description H) ].
- intros [H H0]; exact (description_rel_choice_imp_funct_choice H0 H).
+ [ exact (fun_choice_imp_rel_choice H)
+ | exact (fun_choice_imp_functional_rel_reification H) ].
+ intros [H H0]; exact (functional_rel_reification_and_rel_choice_imp_fun_choice H0 H).
Qed.
(**********************************************************************)
@@ -576,10 +682,6 @@ Qed.
Require Import Wf_nat.
Require Import Decidable.
-Definition FunctionalChoice_on_rel (A B:Type) (R:A->B->Prop) :=
- (forall x:A, exists y : B, R x y) ->
- exists f : A -> B, (forall x:A, R x (f x)).
-
Lemma classical_denumerable_description_imp_fun_choice :
forall A:Type,
FunctionalRelReification_on A nat ->
@@ -601,18 +703,10 @@ Proof.
Qed.
(**********************************************************************)
-(** * Choice on dependent and non dependent function types are equivalent *)
+(** * AC_fun = AC_fun_dep = AC_trunc *)
(** ** Choice on dependent and non dependent function types are equivalent *)
-Definition DependentFunctionalChoice_on (A:Type) (B:A -> Type) :=
- forall R:forall x:A, B x -> Prop,
- (forall x:A, exists y : B x, R x y) ->
- (exists f : (forall x:A, B x), forall x:A, R x (f x)).
-
-Notation DependentFunctionalChoice :=
- (forall A (B:A->Type), DependentFunctionalChoice_on B).
-
(** The easy part *)
Theorem dep_non_dep_functional_choice :
@@ -649,15 +743,34 @@ Proof.
destruct Heq using eq_indd; trivial.
Qed.
-(** ** Reification of dependent and non dependent functional relation are equivalent *)
+(** ** Functional choice and truncation choice are equivalent *)
-Definition DependentFunctionalRelReification_on (A:Type) (B:A -> Type) :=
- forall (R:forall x:A, B x -> Prop),
- (forall x:A, exists! y : B x, R x y) ->
- (exists f : (forall x:A, B x), forall x:A, R x (f x)).
+Theorem functional_choice_to_inhabited_forall_commute :
+ FunctionalChoice -> InhabitedForallCommute.
+Proof.
+ intros choose0 A B Hinhab.
+ pose proof (non_dep_dep_functional_choice choose0) as choose;clear choose0.
+ assert (Hexists : forall x, exists _ : B x, True).
+ { intros x;apply inhabited_sig_to_exists.
+ refine (inhabited_covariant _ (Hinhab x)).
+ intros y;exists y;exact I. }
+ apply choose in Hexists.
+ destruct Hexists as [f _].
+ exact (inhabits f).
+Qed.
-Notation DependentFunctionalRelReification :=
- (forall A (B:A->Type), DependentFunctionalRelReification_on B).
+Theorem inhabited_forall_commute_to_functional_choice :
+ InhabitedForallCommute -> FunctionalChoice.
+Proof.
+ intros choose A B R Hexists.
+ assert (Hinhab : forall x, inhabited {y : B | R x y}).
+ { intros x;apply exists_to_inhabited_sig;trivial. }
+ apply choose in Hinhab. destruct Hinhab as [f].
+ exists (fun x => proj1_sig (f x)).
+ exact (fun x => proj2_sig (f x)).
+Qed.
+
+(** ** Reification of dependent and non dependent functional relation are equivalent *)
(** The easy part *)
@@ -862,3 +975,346 @@ Proof.
rewrite Heq in HR.
assumption.
Qed.
+
+(**********************************************************************)
+(** * About the axiom of choice over setoids *)
+
+Require Import ClassicalFacts PropExtensionalityFacts.
+
+(**********************************************************************)
+(** ** Consequences of the choice of a representative in an equivalence class *)
+
+Theorem repr_fun_choice_imp_ext_prop_repr :
+ RepresentativeFunctionalChoice -> ExtensionalPropositionRepresentative.
+Proof.
+ intros ReprFunChoice A.
+ pose (R P Q := P <-> Q).
+ assert (Hequiv:Equivalence R) by (split; firstorder).
+ apply (ReprFunChoice _ R Hequiv).
+Qed.
+
+Theorem repr_fun_choice_imp_ext_pred_repr :
+ RepresentativeFunctionalChoice -> ExtensionalPredicateRepresentative.
+Proof.
+ intros ReprFunChoice A.
+ pose (R P Q := forall x : A, P x <-> Q x).
+ assert (Hequiv:Equivalence R) by (split; firstorder).
+ apply (ReprFunChoice _ R Hequiv).
+Qed.
+
+Theorem repr_fun_choice_imp_ext_function_repr :
+ RepresentativeFunctionalChoice -> ExtensionalFunctionRepresentative.
+Proof.
+ intros ReprFunChoice A B.
+ pose (R (f g : A -> B) := forall x : A, f x = g x).
+ assert (Hequiv:Equivalence R).
+ { split; try easy. firstorder using eq_trans. }
+ apply (ReprFunChoice _ R Hequiv).
+Qed.
+
+(** *** This is a variant of Diaconescu and Goodman-Myhill theorems *)
+
+Theorem repr_fun_choice_imp_excluded_middle :
+ RepresentativeFunctionalChoice -> ExcludedMiddle.
+Proof.
+ intros ReprFunChoice.
+ apply representative_boolean_partition_imp_excluded_middle, ReprFunChoice.
+Qed.
+
+Theorem repr_fun_choice_imp_relational_choice :
+ RepresentativeFunctionalChoice -> RelationalChoice.
+Proof.
+ intros ReprFunChoice A B T Hexists.
+ pose (D := (A*B)%type).
+ pose (R (z z':D) :=
+ let x := fst z in
+ let x' := fst z' in
+ let y := snd z in
+ let y' := snd z' in
+ x = x' /\ (T x y -> y = y' \/ T x y') /\ (T x y' -> y = y' \/ T x y)).
+ assert (Hequiv : Equivalence R).
+ { split.
+ - split. easy. firstorder.
+ - intros (x,y) (x',y') (H1,(H2,H2')). split. easy. simpl fst in *. simpl snd in *.
+ subst x'. split; intro H.
+ + destruct (H2' H); firstorder.
+ + destruct (H2 H); firstorder.
+ - intros (x,y) (x',y') (x'',y'') (H1,(H2,H2')) (H3,(H4,H4')).
+ simpl fst in *. simpl snd in *. subst x'' x'. split. easy. split; intro H.
+ + simpl fst in *. simpl snd in *. destruct (H2 H) as [<-|H0].
+ * destruct (H4 H); firstorder.
+ * destruct (H2' H0), (H4 H0); try subst y'; try subst y''; try firstorder.
+ + simpl fst in *. simpl snd in *. destruct (H4' H) as [<-|H0].
+ * destruct (H2' H); firstorder.
+ * destruct (H2' H0), (H4 H0); try subst y'; try subst y''; try firstorder. }
+ destruct (ReprFunChoice D R Hequiv) as (g,Hg).
+ set (T' x y := T x y /\ exists y', T x y' /\ g (x,y') = (x,y)).
+ exists T'. split.
+ - intros x y (H,_); easy.
+ - intro x. destruct (Hexists x) as (y,Hy).
+ exists (snd (g (x,y))).
+ destruct (Hg (x,y)) as ((Heq1,(H',H'')),Hgxyuniq); clear Hg.
+ destruct (H' Hy) as [Heq2|Hgy]; clear H'.
+ + split. split.
+ * rewrite <- Heq2. assumption.
+ * exists y. destruct (g (x,y)) as (x',y'). simpl in Heq1, Heq2. subst; easy.
+ * intros y' (Hy',(y'',(Hy'',Heq))).
+ rewrite (Hgxyuniq (x,y'')), Heq. easy. split. easy.
+ split; right; easy.
+ + split. split.
+ * assumption.
+ * exists y. destruct (g (x,y)) as (x',y'). simpl in Heq1. subst x'; easy.
+ * intros y' (Hy',(y'',(Hy'',Heq))).
+ rewrite (Hgxyuniq (x,y'')), Heq. easy. split. easy.
+ split; right; easy.
+Qed.
+
+(**********************************************************************)
+(** ** AC_fun_setoid = AC_fun_setoid_gen = AC_fun_setoid_simple *)
+
+Theorem gen_setoid_fun_choice_imp_setoid_fun_choice :
+ forall A B, GeneralizedSetoidFunctionalChoice_on A B -> SetoidFunctionalChoice_on A B.
+Proof.
+ intros A B GenSetoidFunChoice R T Hequiv Hcompat Hex.
+ apply GenSetoidFunChoice; try easy.
+ apply eq_equivalence.
+ intros * H <-. firstorder.
+Qed.
+
+Theorem setoid_fun_choice_imp_gen_setoid_fun_choice :
+ forall A B, SetoidFunctionalChoice_on A B -> GeneralizedSetoidFunctionalChoice_on A B.
+Proof.
+ intros A B SetoidFunChoice R S T HequivR HequivS Hcompat Hex.
+ destruct SetoidFunChoice with (R:=R) (T:=T) as (f,Hf); try easy.
+ { intros; apply (Hcompat x x' y y); try easy. }
+ exists f. intros x; specialize Hf with x as (Hf,Huniq). intuition. now erewrite Huniq.
+Qed.
+
+Corollary setoid_fun_choice_iff_gen_setoid_fun_choice :
+ forall A B, SetoidFunctionalChoice_on A B <-> GeneralizedSetoidFunctionalChoice_on A B.
+Proof.
+ split; auto using gen_setoid_fun_choice_imp_setoid_fun_choice, setoid_fun_choice_imp_gen_setoid_fun_choice.
+Qed.
+
+Theorem setoid_fun_choice_imp_simple_setoid_fun_choice :
+ forall A B, SetoidFunctionalChoice_on A B -> SimpleSetoidFunctionalChoice_on A B.
+Proof.
+ intros A B SetoidFunChoice R T Hequiv Hexists.
+ pose (T' x y := forall x', R x x' -> T x' y).
+ assert (Hcompat : forall (x x' : A) (y : B), R x x' -> T' x y -> T' x' y) by firstorder.
+ destruct (SetoidFunChoice R T' Hequiv Hcompat Hexists) as (f,Hf).
+ exists f. firstorder.
+Qed.
+
+Theorem simple_setoid_fun_choice_imp_setoid_fun_choice :
+ forall A B, SimpleSetoidFunctionalChoice_on A B -> SetoidFunctionalChoice_on A B.
+Proof.
+ intros A B SimpleSetoidFunChoice R T Hequiv Hcompat Hexists.
+ destruct (SimpleSetoidFunChoice R T Hequiv) as (f,Hf); firstorder.
+Qed.
+
+Corollary setoid_fun_choice_iff_simple_setoid_fun_choice :
+ forall A B, SetoidFunctionalChoice_on A B <-> SimpleSetoidFunctionalChoice_on A B.
+Proof.
+ split; auto using simple_setoid_fun_choice_imp_setoid_fun_choice, setoid_fun_choice_imp_simple_setoid_fun_choice.
+Qed.
+
+(**********************************************************************)
+(** ** AC_fun_setoid = AC! + AC_fun_repr *)
+
+Theorem setoid_fun_choice_imp_fun_choice :
+ forall A B, SetoidFunctionalChoice_on A B -> FunctionalChoice_on A B.
+Proof.
+ intros A B SetoidFunChoice T Hexists.
+ destruct SetoidFunChoice with (R:=@eq A) (T:=T) as (f,Hf).
+ - apply eq_equivalence.
+ - now intros * ->.
+ - assumption.
+ - exists f. firstorder.
+Qed.
+
+Corollary setoid_fun_choice_imp_functional_rel_reification :
+ forall A B, SetoidFunctionalChoice_on A B -> FunctionalRelReification_on A B.
+Proof.
+ intros A B SetoidFunChoice.
+ apply fun_choice_imp_functional_rel_reification.
+ now apply setoid_fun_choice_imp_fun_choice.
+Qed.
+
+Theorem setoid_fun_choice_imp_repr_fun_choice :
+ SetoidFunctionalChoice -> RepresentativeFunctionalChoice .
+Proof.
+ intros SetoidFunChoice A R Hequiv.
+ apply SetoidFunChoice; firstorder.
+Qed.
+
+Theorem functional_rel_reification_and_repr_fun_choice_imp_setoid_fun_choice :
+ FunctionalRelReification -> RepresentativeFunctionalChoice -> SetoidFunctionalChoice.
+Proof.
+ intros FunRelReify ReprFunChoice A B R T Hequiv Hcompat Hexists.
+ assert (FunChoice : FunctionalChoice).
+ { intros A' B'. apply functional_rel_reification_and_rel_choice_imp_fun_choice.
+ - apply FunRelReify.
+ - now apply repr_fun_choice_imp_relational_choice. }
+ destruct (FunChoice _ _ T Hexists) as (f,Hf).
+ destruct (ReprFunChoice A R Hequiv) as (g,Hg).
+ exists (fun a => f (g a)).
+ intro x. destruct (Hg x) as (Hgx,HRuniq).
+ split.
+ - eapply Hcompat. symmetry. apply Hgx. apply Hf.
+ - intros y Hxy. f_equal. auto.
+Qed.
+
+Theorem functional_rel_reification_and_repr_fun_choice_iff_setoid_fun_choice :
+ FunctionalRelReification /\ RepresentativeFunctionalChoice <-> SetoidFunctionalChoice.
+Proof.
+ split; intros.
+ - now apply functional_rel_reification_and_repr_fun_choice_imp_setoid_fun_choice.
+ - split.
+ + now intros A B; apply setoid_fun_choice_imp_functional_rel_reification.
+ + now apply setoid_fun_choice_imp_repr_fun_choice.
+Qed.
+
+(** Note: What characterization to give of
+RepresentativeFunctionalChoice? A formulation of it as a functional
+relation would certainly be equivalent to the formulation of
+SetoidFunctionalChoice as a functional relation, but in their
+functional forms, SetoidFunctionalChoice seems strictly stronger *)
+
+(**********************************************************************)
+(** * AC_fun_setoid = AC_fun + Ext_fun_repr + EM *)
+
+Import EqNotations.
+
+(** ** This is the main theorem in [[Carlström04]] *)
+
+(** Note: all ingredients have a computational meaning when taken in
+ separation. However, to compute with the functional choice,
+ existential quantification has to be thought as a strong
+ existential, which is incompatible with the computational content of
+ excluded-middle *)
+
+Theorem fun_choice_and_ext_functions_repr_and_excluded_middle_imp_setoid_fun_choice :
+ FunctionalChoice -> ExtensionalFunctionRepresentative -> ExcludedMiddle -> RepresentativeFunctionalChoice.
+Proof.
+ intros FunChoice SetoidFunRepr EM A R (Hrefl,Hsym,Htrans).
+ assert (H:forall P:Prop, exists b, b = true <-> P).
+ { intros P. destruct (EM P).
+ - exists true; firstorder.
+ - exists false; easy. }
+ destruct (FunChoice _ _ _ H) as (c,Hc).
+ pose (class_of a y := c (R a y)).
+ pose (isclass f := exists x:A, f x = true).
+ pose (class := {f:A -> bool | isclass f}).
+ pose (contains (c:class) (a:A) := proj1_sig c a = true).
+ destruct (FunChoice class A contains) as (f,Hf).
+ - intros f. destruct (proj2_sig f) as (x,Hx).
+ exists x. easy.
+ - destruct (SetoidFunRepr A bool) as (h,Hh).
+ assert (Hisclass:forall a, isclass (h (class_of a))).
+ { intro a. exists a. destruct (Hh (class_of a)) as (Ha,Huniqa).
+ rewrite <- Ha. apply Hc. apply Hrefl. }
+ pose (f':= fun a => exist _ (h (class_of a)) (Hisclass a) : class).
+ exists (fun a => f (f' a)).
+ intros x. destruct (Hh (class_of x)) as (Hx,Huniqx). split.
+ + specialize Hf with (f' x). unfold contains in Hf. simpl in Hf. rewrite <- Hx in Hf. apply Hc. assumption.
+ + intros y Hxy.
+ f_equal.
+ assert (Heq1: h (class_of x) = h (class_of y)).
+ { apply Huniqx. intro z. unfold class_of.
+ destruct (c (R x z)) eqn:Hxz.
+ - symmetry. apply Hc. apply -> Hc in Hxz. firstorder.
+ - destruct (c (R y z)) eqn:Hyz.
+ + apply -> Hc in Hyz. rewrite <- Hxz. apply Hc. firstorder.
+ + easy. }
+ assert (Heq2:rew Heq1 in Hisclass x = Hisclass y).
+ { apply proof_irrelevance_cci, EM. }
+ unfold f'.
+ rewrite <- Heq2.
+ rewrite <- Heq1.
+ reflexivity.
+Qed.
+
+Theorem setoid_functional_choice_first_characterization :
+ FunctionalChoice /\ ExtensionalFunctionRepresentative /\ ExcludedMiddle <-> SetoidFunctionalChoice.
+Proof.
+ split.
+ - intros (FunChoice & SetoidFunRepr & EM).
+ apply functional_rel_reification_and_repr_fun_choice_imp_setoid_fun_choice.
+ + intros A B. apply fun_choice_imp_functional_rel_reification, FunChoice.
+ + now apply fun_choice_and_ext_functions_repr_and_excluded_middle_imp_setoid_fun_choice.
+ - intro SetoidFunChoice. repeat split.
+ + now intros A B; apply setoid_fun_choice_imp_fun_choice.
+ + apply repr_fun_choice_imp_ext_function_repr.
+ now apply setoid_fun_choice_imp_repr_fun_choice.
+ + apply repr_fun_choice_imp_excluded_middle.
+ now apply setoid_fun_choice_imp_repr_fun_choice.
+Qed.
+
+(**********************************************************************)
+(** ** AC_fun_setoid = AC_fun + Ext_pred_repr + PI *)
+
+(** Note: all ingredients have a computational meaning when taken in
+ separation. However, to compute with the functional choice,
+ existential quantification has to be thought as a strong
+ existential, which is incompatible with proof-irrelevance which
+ requires existential quantification to be truncated *)
+
+Theorem fun_choice_and_ext_pred_ext_and_proof_irrel_imp_setoid_fun_choice :
+ FunctionalChoice -> ExtensionalPredicateRepresentative -> ProofIrrelevance -> RepresentativeFunctionalChoice.
+Proof.
+ intros FunChoice PredExtRepr PI A R (Hrefl,Hsym,Htrans).
+ pose (isclass P := exists x:A, P x).
+ pose (class := {P:A -> Prop | isclass P}).
+ pose (contains (c:class) (a:A) := proj1_sig c a).
+ pose (class_of a := R a).
+ destruct (FunChoice class A contains) as (f,Hf).
+ - intros c. apply proj2_sig.
+ - destruct (PredExtRepr A) as (h,Hh).
+ assert (Hisclass:forall a, isclass (h (class_of a))).
+ { intro a. exists a. destruct (Hh (class_of a)) as (Ha,Huniqa).
+ rewrite <- Ha; apply Hrefl. }
+ pose (f':= fun a => exist _ (h (class_of a)) (Hisclass a) : class).
+ exists (fun a => f (f' a)).
+ intros x. destruct (Hh (class_of x)) as (Hx,Huniqx). split.
+ + specialize Hf with (f' x). simpl in Hf. rewrite <- Hx in Hf. assumption.
+ + intros y Hxy.
+ f_equal.
+ assert (Heq1: h (class_of x) = h (class_of y)).
+ { apply Huniqx. intro z. unfold class_of. firstorder. }
+ assert (Heq2:rew Heq1 in Hisclass x = Hisclass y).
+ { apply PI. }
+ unfold f'.
+ rewrite <- Heq2.
+ rewrite <- Heq1.
+ reflexivity.
+Qed.
+
+Theorem setoid_functional_choice_second_characterization :
+ FunctionalChoice /\ ExtensionalPredicateRepresentative /\ ProofIrrelevance <-> SetoidFunctionalChoice.
+Proof.
+ split.
+ - intros (FunChoice & ExtPredRepr & PI).
+ apply functional_rel_reification_and_repr_fun_choice_imp_setoid_fun_choice.
+ + intros A B. now apply fun_choice_imp_functional_rel_reification.
+ + now apply fun_choice_and_ext_pred_ext_and_proof_irrel_imp_setoid_fun_choice.
+ - intro SetoidFunChoice. repeat split.
+ + now intros A B; apply setoid_fun_choice_imp_fun_choice.
+ + apply repr_fun_choice_imp_ext_pred_repr.
+ now apply setoid_fun_choice_imp_repr_fun_choice.
+ + red. apply proof_irrelevance_cci.
+ apply repr_fun_choice_imp_excluded_middle.
+ now apply setoid_fun_choice_imp_repr_fun_choice.
+Qed.
+
+(**********************************************************************)
+(** * Compatibility notations *)
+Notation description_rel_choice_imp_funct_choice :=
+ functional_rel_reification_and_rel_choice_imp_fun_choice (only parsing).
+
+Notation funct_choice_imp_rel_choice := fun_choice_imp_rel_choice (only parsing).
+
+Notation FunChoice_Equiv_RelChoice_and_ParamDefinDescr :=
+ fun_choice_iff_rel_choice_and_functional_rel_reification (only parsing).
+
+Notation funct_choice_imp_description := fun_choice_imp_functional_rel_reification (only parsing).