Library bourbaki


Require Import ClassicalFacts.
Require Import ChoiceFacts.

Section bourbaki.
  Hypothesis classic : excluded_middle.

  Variable A:Type.
  Variable R:A -> A -> Prop.

  Hypothesis Rrefl : forall a, R a a.
  Hypothesis Rtrans : forall a b c,
    R a b -> R b c -> R a c.

  Definition ordered_set (T:A -> Prop) :=
    forall x y, T x -> T y -> R x y \/ R y x.

  Definition upper_bound (T:A -> Prop) (bnd:A) :=
    forall x, T x -> R x bnd.

  Definition least_upper_bound (T:A -> Prop) (bnd:A) :=
    upper_bound T bnd /\
    forall bnd', upper_bound T bnd' -> R bnd bnd'.

  Hypothesis chain_complete :
    forall T t, ordered_set T -> T t ->
      exists bnd, least_upper_bound T bnd.

  Definition inflationary (f:A -> A) :=
    forall x, R x (f x).

  Section fixpoint.

    Variable f: A -> A.
    Hypothesis f_inflate : inflationary f.
    Hypothesis f_iso : forall x y,
      R x y -> R y x -> R (f x) (f y).

    Variable x0:A.

    Record closed (B:A -> Prop) : Prop :=
    { cl_incl : B x0
    ; cl_iso : forall x y, R x y -> R y x -> B x -> B y
    ; cl_f : forall x, B x -> B (f x)
    ; cl_chain : forall T t,
        ordered_set T -> T t ->
        (forall x, T x -> B x) ->
        exists bnd,
          B bnd /\
          least_upper_bound T bnd
    }.

    Definition all_closed (x:A) : Prop :=
      forall B, closed B -> B x.

    Lemma all_closed_closed : closed all_closed.

    Lemma closed_restrict : forall B,
      closed B -> closed (fun x => B x /\ R x0 x).

    Lemma all_closed_x0 : forall x,
      all_closed x -> R x0 x.

    Definition normal x :=
      all_closed x /\
      forall y, all_closed y ->
        R y x -> R x y \/ R (f y) x.

    Section normal1.
      Variables x y:A.
      Hypothesis Hx : normal x.
      Hypothesis Hy : all_closed y.

      Let outer z := all_closed z /\ (R z x \/ R (f x) z).

      Lemma outer_closed : closed outer.

      Lemma normal1 : R y x \/ R (f x) y.
    End normal1.

    Lemma normal2 : closed normal.

    Lemma all_closed_chain : ordered_set all_closed.

    Theorem bourbaki :
      exists x, R x0 x /\ R x (f x) /\ R (f x) x.
  End fixpoint.

  Definition maximal x :=
    forall y, R x y -> R y x.

  Definition is_quot (P:A -> Prop) :=
    (exists a, P a) /\
    (forall x y, P x -> P y -> R x y /\ R y x).

  Definition quot := { P:A -> Prop | is_quot P }.

  Program Definition q (x:A) : quot :=
    fun y => R x y /\ R y x.

  Hypothesis prop_ext : prop_extensionality.
  Hypothesis fun_ext : forall A B (f g:A -> B),
    (forall x, f x = g x) -> f = g.
  Hypothesis choose: FunctionalChoice.

  Lemma q_eq : forall x y,
    R x y -> R y x -> q x = q y.

  Theorem zorn :
    forall x0:A, exists x, maximal x.

End bourbaki.