Section PACO.
#[local] Hint Resolve le_join_lattice_introl le_join_lattice_intror join_lattice_le_intro bot_lattice_le_intro : core.
Context {A : Type}.
Let D : Type := ensemble A.
#[local]
Instance ensemble_isUpperSemilattice : isUpperSemilattice D :=
{ join_lattice := @E.union A
; bot_lattice := @E.empty A
; join_lattice_spec := union_join_lattice_spec
; bot_lattice_spec := empty_bot_lattice_spec
}.
Variant paco' {paco_F : D -> D} (F : D -> D) (X : D) : D :=
| mk_paco' (WITNESS : D)
(INCL : WITNESS \subseteq join_lattice X (paco_F X))
: F WITNESS \subseteq paco' F X.
#[global]
Instance ensemble_isCoLa : isCola D :=
fun Xs : ensemble D => @exist D (fun sup_Xs : D => is_supremum_of sup_Xs Xs) (E.unions Xs) (unions_is_supremum Xs).
#[projections(primitive)]
CoInductive paco (F : D -> D) (X : D) (z : A) : Prop :=
Fold_paco { unfold_paco : z \in paco' (paco_F := paco F) F X }.
Definition Paco (f : `[D -> D]) : `[D -> D] :=
@exist (D -> D) isMonotonic1 (paco (proj1_sig f)) (paco_preserves_monotonicity (proj1_sig f) (proj2_sig f)).
Proof with eauto with *.
pose (proj1_sig f) as F.
assert (claim1 : F (join_lattice bot_lattice (paco F bot_lattice)) =< paco F bot_lattice) by exact (paco_fold F bot_lattice).
assert (claim2 : paco F bot_lattice =< F (join_lattice bot_lattice (paco F bot_lattice))) by exact (paco_unfold F bot_lattice (proj2_sig f)).
assert (FIXEDPOINT : paco F bot_lattice == F (paco F bot_lattice)).
{ eapply @leProp_antisymmetry with (A_isProset := E.ensemble_isProset).
- rewrite claim2 at 1. eapply (proj2_sig f). eapply join_lattice_le_intro...
- rewrite <- claim1 at 2. eapply (proj2_sig f). eapply le_join_lattice_intror...
}
assert (IS_SUPREMUM : is_supremum_of (proj1_sig (nu f)) (postfixedpointsOf F)) by eapply nu_is_supremum_of_postfixedpointsOf.
pose proof (nu_f_is_gfpOf_f f) as [claim3 claim4]; unnw.
do 2 red in claim3. fold F in claim3.
assert (to_show : F (proj1_sig (nu f)) =< paco F bot_lattice).
{ cofix CIH. intros z z_in. econstructor. revert z z_in. apply mk_paco'.
intros z z_in. right. eapply CIH. rewrite <- claim3. exact (z_in).
}
rewrite <- claim3 in to_show. eapply @leProp_antisymmetry with (A_isProset := E.ensemble_isProset)...
Qed.

Lemma unfoldPaco (f : `[D -> D])
: forall X : D, proj1_sig (Paco f) X == proj1_sig f (join_lattice X (proj1_sig (Paco f) X)).