Section BASIC1.
#[local] Close Scope nat_scope.
#[local] Notation "x >= y" := (y =< x) (only parsing) : type_scope.
Definition fixedpointsOf {D : Type} `{SETOID : isSetoid D} (f : D -> D) : ensemble D :=
fun x => x == f x.
#[global]
Instance fixedpointsOf_eqPropCompatible1 {D : Type} `{SETOID : isSetoid D}
: eqPropCompatible1 (@fixedpointsOf D SETOID).
Definition prefixedpointsOf {D : Type} `{PROSET : isProset D} (f : D -> D) : ensemble D :=
fun x => x >= f x.
Definition postfixedpointsOf {D : Type} `{PROSET : isProset D} (f : D -> D) : ensemble D :=
fun x => x =< f x.
Definition upperboundsOf {D : Type} `{PROSET : isProset D} (X : ensemble D) : ensemble D :=
fun u => forall x : D, forall IN : x \in X, x =< u.
Definition lowerboundsOf {D : Type} `{PROSET : isProset D} (X: ensemble D) : ensemble D :=
fun l => forall x : D, forall IN : x \in X, x >= l.
Definition is_supremum_of {D : Type} `{PROSET : isProset D} (sup_X : D) (X : ensemble D) : Prop :=
forall u : D, sup_X =< u <-> u \in upperboundsOf X.
Definition is_infimum_of {D : Type} `{PROSET : isProset D} (inf_X : D) (X : ensemble D) : Prop :=
forall l : D, inf_X >= l <-> l \in lowerboundsOf X.
#[global]
Add Parametric Morphism {D : Type} `{SETOID : isSetoid D}
: fixedpointsOf with signature (eqProp ==> eqProp)
as fixedpointsOf_compatWith_eqProp.
#[local] Hint Unfold fixedpointsOf prefixedpointsOf postfixedpointsOf upperboundsOf lowerboundsOf is_supremum_of is_infimum_of : simplication_hints.
Context {D : Type} `{PROSET : isProset D}.
#[local] Existing Instance pi_isProset.
#[global]
Instance prefixecpointsOf_eqPropCompatible1
: eqPropCompatible1 (@prefixedpointsOf D PROSET).
#[global]
Instance postfixedpointsOf_eqPropCompatible1
: eqPropCompatible1 (@postfixedpointsOf D PROSET).
#[global]
Add Parametric Morphism
: (@upperboundsOf D PROSET) with signature (eqProp ==> eqProp)
as upperboundsOf_compatWith_eqProp.
#[global]
Add Parametric Morphism
: (@lowerboundsOf D PROSET) with signature (eqProp ==> eqProp)
as lowerboundsOf_compatWith_eqProp.
#[global]
Add Parametric Morphism
: (@is_supremum_of D PROSET) with signature (eqProp ==> eqProp ==> iff)
as is_supremum_of_compatWith_eqProp.
#[global]
Add Parametric Morphism
: (@is_infimum_of D PROSET) with signature (eqProp ==> eqProp ==> iff)
as is_infimum_of_compatWith_eqProp.
#[local] Hint Resolve supremum_monotonic : poset_hints.
#[local] Hint Resolve supremum_unique : poset_hints.
#[local] Hint Resolve supremum_congruence : poset_hints.
Definition map_suprema (Xs : ensemble (ensemble D)) : ensemble D :=
Xs >>= fun X_i => fun sup_X_i => is_supremum_of sup_X_i X_i.
Proof with eauto with *.
eapply SUPREMUM... rewrite in_map_suprema_iff...
Qed.
#[local] Hint Resolve supremum_of_map_suprema_ge_suprema : poset_hints.

Theorem supremum_of_map_suprema_is_supremum_of_unions (Xs : ensemble (ensemble D)) (sup : D)
(SUPS_EXIST : forall X, X \in Xs -> exists sup_X, is_supremum_of sup_X X)
: is_supremum_of sup (map_suprema Xs) <-> is_supremum_of sup (E.unions Xs).