Timings for AC.v
From HoTT Require Import ExcludedMiddle canonical_names.
From HoTT Require Import HIT.unique_choice.
From HoTT Require Import Spaces.Card.
From HoTT.Sets Require Import Ordinals.
Local Open Scope hprop_scope.
(** * Set-theoretic formulation of the axiom of choice (AC) *)
Monomorphic Axiom Choice : Type0.
Definition Choice_type :=
forall (X Y : HSet) (R : X -> Y -> HProp), (forall x, hexists (R x)) -> hexists (fun f => forall x, R x (f x)).
Axiom AC : forall `{Choice}, Choice_type.
Instance is_global_axiom_propresizing : IsGlobalAxiom Choice := {}.
(** * The well-ordering theorem implies AC *)
Lemma WO_AC {LEM : ExcludedMiddle} :
(forall (X : HSet), hexists (fun (A : Ordinal) => InjectsInto X A)) -> Choice_type.
eapply merely_destruct; try exact H.
eapply merely_destruct; try exact HA.
assert (HR' : hexists (fun y => merely (R x y * forall y', R x y' -> f y < f y' \/ f y = f y'))).
pose proof (HAR := ordinal_has_minimal_hsolutions A (fun a => Build_HProp (merely (exists y, f y = a /\ R x y)))).
eapply merely_destruct; try apply HAR.
eapply merely_destruct; try exact (HR x).
eapply merely_destruct; try exact H1.
edestruct (@iota Y) as [y Hy]; try exact y.
eapply merely_destruct; try exact Hy.
eapply merely_destruct; try apply Hy'.
eapply merely_destruct; try apply (H2 y'); trivial.
eapply merely_destruct; try apply (H4 y); trivial.
intros [H6| -> ]; trivial.
apply (irreflexive_ordinal_relation _ _ _ (f y)).
apply (ordinal_transitivity _ (f y')); trivial.
eapply merely_destruct; try exact Hy.