Section SCOTT_LAM.
Context {D : Type} {D' : Type} {D'' : Type} {PROSET : isProset D} {PROSET' : isProset D'} {PROSET'' : isProset D''} {CPO : isCpo D} {CPO' : isCpo D'} {CPO'' : isCpo D''}.
Let scottLam1 (f : `[(D * D') -> D'']) (x1 : D) (x2 : D') : D'' :=
proj1_sig f (x1, x2).
Let scottLam2 (f : `[(D * D') -> D'']) (x1 : D) : `[D' -> D''] :=
@exist (D' -> D'') isContinuous (scottLam1 f x1) (f2_cont_if_f_cont (proj1_sig f) x1 (proj2_sig f)).
Proof with eauto with *.
assert (f_isMonotonic : isMonotonic1 (proj1_sig f)).
{ eapply ScottContinuousMap_isMonotonic. exact (proj2_sig f). }
pose proof (proj2 (seperately_monotonic_iff_monotonic (proj1_sig f)) f_isMonotonic) as [? ?].
assert (scottLam2_f_isMonotonic : isMonotonic1 (scottLam2 f)).
{ intros x1 x1' x1_le_x1' x2. simpl. unfold scottLam1. eapply H... }
assert (scottLam2_f_preserves_eqProp : eqPropCompatible1 (scottLam2 f)).
{ ii. eapply leProp_antisymmetry; eapply scottLam2_f_isMonotonic... }
eapply the_main_reason_for_introducing_ScottTopology; trivial.
intros X1 X1_isDirected; unnw. set (sup_X1 := supremum_cpo X1 X1_isDirected).
assert (Y_isDirected : isDirected (E.image (scottLam2 f) X1)).
{ eapply preservesDirectedness_if_isMonotonic... }
set (Y := E.image (scottLam2 f) X1). fold Y in Y_isDirected. set (sup_Y := supremum_cpo Y Y_isDirected).
assert (sup_X1_is_supremum_of_X1 : is_supremum_of sup_X1 X1) by exact (supremum_cpo_spec X1 X1_isDirected).
assert (sup_Y_is_supremum_of_Y : is_supremum_of sup_Y Y) by exact (supremum_cpo_spec Y Y_isDirected).
exists (sup_X1), (sup_Y). split; trivial. split; trivial.
assert (claim1 : forall x1, x1 \in X1 -> forall x2, proj1_sig f (x1, x2) =< proj1_sig f (sup_X1, x2)).
{ intros x1 x1_in_X1 x2. eapply f_isMonotonic. split; [eapply sup_X1_is_supremum_of_X1 | reflexivity]... }
intros x2. simpl. unfold scottLam1. pose proof (f_sup_X1_x2_eq_sup_f_X1_x2 (proj1_sig f) x2 X1 sup_X1 (proj2_sig f) X1_isDirected sup_X1_is_supremum_of_X1) as claim2. eapply supremum_unique.
- exact (claim2).
- eapply supOfScottContinuousMaps_isSupremum.
- intros z. split.
+ intros z_in. s!. destruct z_in as [x1 [? x1_in_X1]]; subst z. exists (scottLam2 f x1). split. reflexivity. unfold scottLam2. econs... reflexivity.
+ intros z_in. rewrite E.in_image_iff in z_in. destruct z_in as [f1 [? f1_in_Y]]; subst z. unfold Y in f1_in_Y. rewrite E.in_image_iff in f1_in_Y. destruct f1_in_Y as [x1 [? x1_in_X1]]; subst f1... econs... reflexivity.
Qed.
Let scottLam3 (f : `[(D * D') -> D'']) : `[D -> `[D' -> D'']] :=
@exist (D -> `[D' -> D'']) isContinuous (scottLam2 f) (scottLam2_isContinuous f).

Lemma scottLam3_isContinuous
: isContinuous scottLam3.