Brendan Hart 2019-2020 Addition by Tom de Jong in July 2024. \begin{code} {-# OPTIONS --safe --without-K #-} open import MLTT.Spartan open import UF.FunExt open import UF.PropTrunc module DomainTheory.Basics.Curry (pt : propositional-truncations-exist) (fe : β {π€ π₯} β funext π€ π₯) (π₯ : Universe) where open PropositionalTruncation pt open import DomainTheory.Basics.Dcpo pt fe π₯ open import DomainTheory.Basics.Exponential pt fe π₯ open import DomainTheory.Basics.Miscelanea pt fe π₯ open import DomainTheory.Basics.Pointed pt fe π₯ open import DomainTheory.Basics.Products pt fe open import DomainTheory.Basics.ProductsContinuity pt fe π₯ open import UF.Subsingletons open import UF.Subsingletons-FunExt open DcpoProductsGeneral π₯ module _ (π : DCPO {π€} {π€'}) (π : DCPO {π£} {π£'}) (π : DCPO {π¦} {π¦'}) where curryα΅αΆα΅α΅ : DCPO[ (π Γα΅αΆα΅α΅ π) , π ] β DCPO[ π , π βΉα΅αΆα΅α΅ π ] curryα΅αΆα΅α΅ (a , a-is-continuous) = f , f-is-continuous where f : β¨ π β© β β¨ π βΉα΅αΆα΅α΅ π β© f = continuousβcontinuous-in-prβ π π π (a , a-is-continuous) f-is-continuous : (I : π₯ Μ) (Ξ± : I β β¨ π β©) (Ξ΄ : is-Directed π Ξ±) β is-sup (underlying-order (π βΉα΅αΆα΅α΅ π)) (f (β π Ξ΄)) (f β Ξ±) f-is-continuous I Ξ± Ξ΄ = u , v where u : (i : I) β ((f β Ξ±) i) ββ¨ π βΉα΅αΆα΅α΅ π β© (f (β π Ξ΄)) u i e = sup-is-upperbound (underlying-order π) (continuity-of-function π π a-fixed-e I Ξ± Ξ΄) i where a-fixed-e : DCPO[ π , π ] a-fixed-e = continuousβcontinuous-in-prβ π π π (a , a-is-continuous) e v : (uβ : β¨ π βΉα΅αΆα΅α΅ π β©) β ((i : I) β f (Ξ± i) ββ¨ π βΉα΅αΆα΅α΅ π β© uβ) β f (β π Ξ΄) ββ¨ π βΉα΅αΆα΅α΅ πΒ β© uβ v uβ p e = eβ (underlying-function π π uβ e) (Ξ» i β p i e) where a-fixed-e : DCPO[ π , π ] a-fixed-e = continuousβcontinuous-in-prβ π π π (a , a-is-continuous) e eβ : (uβ : β¨ π β©) β ((i : I) β (underlying-function π π a-fixed-e) (Ξ± i) ββ¨ π β© uβ) β (underlying-function π π a-fixed-e) (β π Ξ΄) ββ¨ π β© uβ eβ = sup-is-lowerbound-of-upperbounds (underlying-order π) (continuity-of-function π π a-fixed-e I Ξ± Ξ΄) uncurryα΅αΆα΅α΅ : DCPO[ π , π βΉα΅αΆα΅α΅ π ] β DCPO[ (π Γα΅αΆα΅α΅ π) , π ] uncurryα΅αΆα΅α΅ π@(f , f-is-continuous) = g , continuous-in-argumentsβcontinuous π π π g πβπ-is-continuous πβπ-is-continuous where f-is-monotone : is-monotone π (π βΉα΅αΆα΅α΅ π) f f-is-monotone = monotone-if-continuous π (π βΉα΅αΆα΅α΅ π) π πβπ-is-continuous : (e : β¨ π β©) β is-continuous π π (Ξ» d β underlying-function π π (f d) e) πβπ-is-continuous e I Ξ± Ξ΄ = u , v where u : is-upperbound (underlying-order π) (underlying-function π π (f (β π Ξ΄)) e) (pointwise-family π π (f β Ξ±) e) u i = f-is-monotone (Ξ± i) (β π Ξ΄) (β-is-upperbound π Ξ΄ i) e v : (z : β¨ π β©) β ((i : I) β (underlying-function π π ((f β Ξ±) i) e) ββ¨ π β© z) β (underlying-function π π (f (β π Ξ΄)) e) ββ¨ π β© z v z p = transport (Ξ» - β - ββ¨ π β© z) (ii β»ΒΉ) β-is-lowerbound where β¨fβΞ±β©i-is-directed : is-Directed (π βΉα΅αΆα΅α΅ π) (f β Ξ±) β¨fβΞ±β©i-is-directed = image-is-directed π (π βΉα΅αΆα΅α΅ π) {f} f-is-monotone {I} {Ξ±} Ξ΄ β¨fβΞ±β©ie-is-directed : is-Directed π (pointwise-family π π (f β Ξ±) e) β¨fβΞ±β©ie-is-directed = pointwise-family-is-directed π π (f β Ξ±) β¨fβΞ±β©i-is-directed e β-is-lowerbound : (β π β¨fβΞ±β©ie-is-directed) ββ¨ π β© z β-is-lowerbound = β-is-lowerbound-of-upperbounds π β¨fβΞ±β©ie-is-directed z p i : f (β π Ξ΄) οΌ β (π βΉα΅αΆα΅α΅ π) β¨fβΞ±β©i-is-directed i = continuous-β-οΌ π (π βΉα΅αΆα΅α΅ π) (f , f-is-continuous) Ξ΄ ii : underlying-function π π (f (β π Ξ΄)) e οΌ β π β¨fβΞ±β©ie-is-directed ii = ap (Ξ» - β underlying-function π π - e) i πβπ-is-continuous : (d : β¨ π β©) β is-continuous π π (Ξ» e β underlying-function π π (f d) e) πβπ-is-continuous d = continuity-of-function π π (f d) g : β¨ π Γα΅αΆα΅α΅ π β© β β¨ π β© g p = underlying-function π π (f (prβ p)) (prβ p) module _ (π : DCPOβ₯ {π€} {π€'}) (π : DCPOβ₯ {π£} {π£'}) (π : DCPOβ₯ {π¦} {π¦'}) where curryα΅αΆα΅α΅β₯ : DCPOβ₯[ π Γα΅αΆα΅α΅β₯ π , π ] β DCPOβ₯[ π , π βΉα΅αΆα΅α΅β₯ π ] curryα΅αΆα΅α΅β₯ f = curryα΅αΆα΅α΅ (π β») (π β») ( π β») f uncurryα΅αΆα΅α΅β₯ : DCPOβ₯[ π , π βΉα΅αΆα΅α΅β₯ π ] β DCPOβ₯[ π Γα΅αΆα΅α΅β₯ π , π ] uncurryα΅αΆα΅α΅β₯ f = uncurryα΅αΆα΅α΅ (π β») (π β») (π β») f module _ (π : DCPO {π€} {π€'}) (π : DCPO {π£} {π£'}) where eval : DCPO[ (π βΉα΅αΆα΅α΅ π) Γα΅αΆα΅α΅ π , π ] eval = f , c where f : β¨ (π βΉα΅αΆα΅α΅ π) Γα΅αΆα΅α΅ π β© β β¨ π β© f (g , d) = underlying-function π π g d f-is-monotone : is-monotone ((π βΉα΅αΆα΅α΅ π) Γα΅αΆα΅α΅ π) π f f-is-monotone (gβ , dβ) (gβ , dβ) (g-β , d-β) = f (gβ , dβ) ββ¨ π β©[ monotone-if-continuous π π gβ dβ dβ d-β ] f (gβ , dβ) ββ¨ π β©[ g-β dβ ] f (gβ , dβ) ββ¨ π β© c : is-continuous ((π βΉα΅αΆα΅α΅ π) Γα΅αΆα΅α΅ π) π f c = continuous-in-argumentsβcontinuous (π βΉα΅αΆα΅α΅ π) π π f continuousβ continuousβ where continuousβ : (e : β¨ π β©) β is-continuous (π βΉα΅αΆα΅α΅ π) π (Ξ» d β f (d , e)) continuousβ d I Ξ± Ξ΄ = u , v where u : is-upperbound (underlying-order π) (f (β (π βΉα΅αΆα΅α΅ π) {I} {Ξ±} Ξ΄ , d)) (Ξ» z β f (Ξ± z , d)) u i = f-is-monotone (Ξ± i , d) (β (π βΉα΅αΆα΅α΅ π) {I} {Ξ±} Ξ΄ , d) (β-is-upperbound (π βΉα΅αΆα΅α΅ π) {I} {Ξ±} Ξ΄ i , reflexivity π d) v : (y : β¨ π β©) β ((i : I) β f (Ξ± i , d) ββ¨ π β© y) β f (β (π βΉα΅αΆα΅α΅ π) {I} {Ξ±} Ξ΄ , d) ββ¨ π β© y v y p = β-is-lowerbound-of-upperbounds π isdirβ y p where isdirβ : is-Directed π (pointwise-family π π Ξ± d) isdirβ = pointwise-family-is-directed π π Ξ± Ξ΄ d continuousβ : (d : β¨ π βΉα΅αΆα΅α΅ π β©) β is-continuous π π (Ξ» e β f (d , e)) continuousβ g I Ξ± Ξ΄ = u , v where u : is-upperbound (underlying-order π) (f (g , β π Ξ΄)) (Ξ» z β f (g , Ξ± z)) u i = f-is-monotone (g , Ξ± i) (g , β π Ξ΄) ((reflexivity (π βΉα΅αΆα΅α΅ π) g) , (β-is-upperbound π Ξ΄ i)) v : (y : β¨ π β©) β ((i : I) β f (g , Ξ± i) ββ¨ π β© y) β f (g , β π Ξ΄) ββ¨ π β© y v y p = transport (Ξ» - β - ββ¨ π β© y) (e β»ΒΉ) q where e : f (g , β π Ξ΄) οΌ β π (image-is-directed π π (monotone-if-continuous π π g) Ξ΄) e = continuous-β-οΌ π π g Ξ΄ q : (β π (image-is-directed π π (monotone-if-continuous π π g) Ξ΄)) ββ¨ π β© y q = β-is-lowerbound-of-upperbounds π (image-is-directed π π (monotone-if-continuous π π g) Ξ΄) y p \end{code} Added 3 July 2024 by Tom de Jong. We introduce two abbreviations for readability. \begin{code} private πα΄° = π βΉα΅αΆα΅α΅ π ev = underlying-function (πα΄° Γα΅αΆα΅α΅ π) π eval βΉα΅αΆα΅α΅-is-exponential : (π' : DCPO {π¦} {π¦'}) (f : β¨ π' Γα΅αΆα΅α΅ π β© β β¨ π β©) β is-continuous (π' Γα΅αΆα΅α΅ π) π f β β! fΜ κ (β¨ π' β© β β¨ πα΄° β©) , is-continuous π' πα΄° fΜ Γ ev β (Ξ» (d' , d) β fΜ d' , d) βΌ f βΉα΅αΆα΅α΅-is-exponential π' f cf = (fΜ , fΜ -is-continuous , βΌ-refl) , fΜ -is-unique where C : DCPO[ π' , πα΄° ] C = curryα΅αΆα΅α΅ π' π π (f , cf) fΜ = prβ C fΜ -is-continuous : is-continuous π' πα΄° fΜ fΜ -is-continuous = prβ C fΜ -is-unique : is-central _ (fΜ , fΜ -is-continuous , βΌ-refl) fΜ -is-unique (g , g-cont , g-eq) = to-subtype-οΌ (Ξ» h β Γ-is-prop (being-continuous-is-prop π' πα΄° h) (Ξ -is-prop fe (Ξ» _ β sethood π))) (dfunext fe (Ξ» d' β to-continuous-function-οΌ π π (Ξ» d β g-eq (d' , d)) β»ΒΉ)) \end{code} End of addition \begin{code} module _ (π : DCPOβ₯ {π€} {π€'}) (π : DCPOβ₯ {π£} {π£'}) where evalβ₯ : DCPOβ₯[ (π βΉα΅αΆα΅α΅β₯ π) Γα΅αΆα΅α΅β₯ π , π ] evalβ₯ = eval (π β») (π β») \end{code}