Commutative Monads for Probabilistic Programming Languages
Xiaodong Jia, Bert Lindenhovius, Michael Mislove, Vladimir Zamdzhiev
aa r X i v : . [ c s . L O ] J a n Commutative Monads for ProbabilisticProgramming Languages
Xiaodong Jia ∗‡ , Bert Lindenhovius † , Michael Mislove ‡ and Vladimir Zamdzhiev §∗ School of Mathematics, Hunan University, Changsha, 410082, China † Department of Knowledge-Based Mathematical Systems, Johannes Kepler Universität, Linz, Austria ‡ Department of Computer Science, Tulane University, New Orleans, LA, USA § Université de Lorraine, CNRS, Inria, LORIA, F 54000 Nancy, France
Abstract
A long-standing open problem in the semantics of programming languages supporting probabilistic choice is to find acommutative monad for probability on the category DCPO. In this paper we present three such monads and a general constructionfor finding even more. We show how to use these monads to provide a sound and adequate denotational semantics for theProbabilistic FixPoint Calculus (PFPC) – a call-by-value simply-typed lambda calculus with mixed-variance recursive types, termrecursion and probabilistic choice. We also show that in the special case where we consider continuous dcpo’s, then all threemonads coincide with the valuations monad of Jones and we fully characterise the induced Eilenberg-Moore categories by showingthat they are all isomorphic to the category of continuous Kegelspitzen of Keimel and Plotkin.
I. I
NTRODUCTION
Probabilistic methods now are a staple of computation. The initial discovery of randomized algorithms [1] was quicklyfollowed by the definition of Probabilistic Turing machines and related complexity classes [2]. There followed advances ina number of areas, including, e.g., process calculi, probabilistic model checking and verification [3]–[5], right through to therecent development of statistical probabilistic programming languages (cf. [6]–[8]), not to mention the crucial role probabilityplays in quantum programming languages [9], [10].
Domain theory , a staple of denotational semantics, has struggled to keep up with these advances. Domain theory encompassestwo broad classes of objects: directed complete partial orders (dcpo’s) , based on an order-theoretic view of computation, andthe smaller class of (continuous) domains , those dcpo’s that also come equipped with a notion of approximation. However,adding probabilistic choice to the domain-theoretic approach has been a challenge. The canonical model of (sub)probabilitymeasures in domain theory is the family of valuations – certain maps from the lattice of open subsets of a dcpo to the unitinterval. It is well-known that these valuations form a monad V on DCPO (the category of dcpo’s and Scott-continuousfunctions) and on
DOM (the full subcategory of
DCPO consisting of domains) [11], [12].In fact, the monad V on DOM is commutative [12], which is important for two reasons: (1) its commutativity is equivalentto the Fubini Theorem [12], a cornerstone of integration theory and (2) computationally, commutativity of a monad togetherwith adequacy can be used to establish contextual equivalences for effectful programs. However, in order to do so, one typicallyneeds a Cartesian closed category for the semantic model, and
DOM is not closed; in fact, despite repeated attempts, it remainsunknown whether there is any
Cartesian closed category of domains on which V is an endofunctor; this is the well-known Jung-Tix Problem [13]. On the other hand, it also is unknown if the monad V is commutative on the larger Cartesian closedcategory DCPO . In this paper, we offer a solution to this conundrum.
A. Our contributions
We use topological methods to construct a commutative valuations monad M on DCPO , as follows: it is straightforwardto show the family S D of simple valuations on D can be equipped with the structure of a commutative monad, but S D isnot a dcpo, in general. So, we complete S D by taking the smallest subdcpo M D ⊆ V D that contains S D . This defines theobject-mapping of a monad M on DCPO . The unit, multiplication and strength of the monad M at D are given by therestrictions of the same operations of V to M D. Topological arguments then imply that M is a commutative valuations monadon DCPO .In fact, there are several completions of S D that give rise to commutative valuations monads on DCPO . These completionsare determined by so-called K -categories, introduced by Keimel and Lawson [14]. This observation allows us to define twoadditional commutative valuations monads, W and P , on DCPO simply by specifying their corresponding K -categories.Finally, while we have identified three such K -categories, there likely are more that meet our requirements, each of whichwould define yet another commutative monad of valuations on DCPO containing S .With this background, we now summarise our main results. ommutative monads : A K -category is a full subcategory of the category T of T -spaces satisfying properties thatimply it determines a completion of each T -space among the objects of the K -category. For example, each K -category definesa completion of a poset endowed with its Scott topology, among the dcpo’s in the K -category. In particular, each K -categorydetermines a completion of the family S D when considered as a subset of V D , for each dcpo D .By specifying an additional constraint on K -categories, we can show the corresponding completions of S define commutativemonads on DCPO . We identify three commutative monads concretely: M , W and P , corresponding to the K -categories ofd-spaces, that of well-filtered spaces and that of sober spaces, respectively (see Theorem 8 and Theorem 22). As part of ourconstruction, we also prove the most general Fubini Theorem for dcpo’s yet available (see Theorem 21). Eilenberg-Moore Algebras : All three of M , W and P restrict to monads on DOM , where they coincide with V . Wecharacterize their Eilenberg-Moore categories over DOM by showing they are isomorphic to the category of continuousKegelspitzen and Scott-continuous linear maps [15]; this corrects an error in [12] (see Remark 36 below).On the larger category
DCPO , we show the Eilenberg-Moore algebras of our monads M , W and P are Kegelspitzen(see Subsection III-E). It is unknown if every Kegelspitze is an M -algebra, but we believe this to be the case. Semantics : We consider the
Probabilistic FixPoint Calculus ( PFPC ) – a call-by-value simply-typed lambda calculuswith mixed-variance recursive types, term recursion and probabilistic choice (see Section II). We show that each of the Kleislicategories of our three commutative monads is a sound and computationally adequate model of
PFPC (see Section V). Moreover,we show that adequacy holds in a strong sense (Theorem 55), i.e., the interpretation of each term is a (potentially infinite)convex sum of the values it reduces to.
B. Related work
The first dcpo model for probabilistic choice was given in [16], but this preceded Moggi’s seminal work using Kleislicategories to model computational effects [17]. The work closest to ours is Jones’ thesis [12] (see also [11]), which considersthe same language
PFPC , but with a slightly different syntax. This work is based on an early version of
FPC , and uses theKleisli category of V over DCPO as the semantic model. While soundness and adequacy theorems are included in [12], theproof of adequacy does not identify a semantic space on which V is commutative, instead offering arguments based on thecommutativity of S , and on realizing the valuations needed to interpret the language as directed suprema of simple valuations.Our semantic results improve those of Jones, because the commutativity of our monads together with adequacy allows us toestablish a larger class of contextual equivalences.Another related paper is [18], where the authors describe a different construction for a commutative monad for probability.The construction in [18] is based on functional-analytic techniques similar to those in [19], [20], whereas ours is based on thetopological and categorical methods in [21]. Furthermore, the two constructions yield distinct monads. With our construction,we identify three probabilistic commutative monads, study the structure of the induced Eilenberg-Moore and Kleisli categoriesand then prove semantic results such as soundness and adequacy for PFPC . The work in [18] constructs yet another commutativemonad that is used to study a different language (a real
PCF -like language with sampling and conditioning) with a semanticsthat reflects a concern for implementability and computability.Other related work includes [22], where the authors use probabilistic coherence spaces to provide a fully abstract model of aprobabilistic call-by-push-value language with recursive types. This work builds on previous work [23] which describes a fullyabstract model of probabilistic
PCF also based on probabilistic coherence spaces. Recently, quasi-Borel spaces were introducedin [24] and they were later used to provide a sound and adequate model of
SFPC (a statistical probabilistic programminglanguage with recursive types, sampling and conditioning) in [8]. Compared to probabilistic coherence spaces and quasi-Borelspaces, our methods are based on the traditional domain-theoretic approach and its well-established connections to probabilitytheory [25]–[27]; we hope to exploit these connections in future work.The paper [28] uses Kegelsptizen to provide a sound and adequate model for probabilistic
PCF . The author then discussesa possible interpretation of a version of linear
PFPC without contraction or a !-modality (which means the system is stronglynormalising), but [28] does not state any soundness, nor adequacy results for it.II. S
YNTAX AND O PERATIONAL S EMANTICS
In this section we describe the syntax and operational semantics of our language. The language we consider is the
ProbabilisticFixPoint Calculus ( PFPC ). The presentation we choose for
PFPC is exactly the same as
FPC [29]–[31] together with the additionof one extra term ( M or p N ) for probabilistic choice. The same language is also considered by Jones [12], but with a slightlydifferent syntax. A. The Types of
PFPC
Recursive types in
PFPC are formed in the same way as in
FPC . We use
X, Y to range over type variables and we use Θ to range over type contexts . A type context Θ = X , . . . , X n is well-formed , written Θ ⊢ , if all type variables within it aredistinct. We use A, B to range over the types of our language which are defined in Figure 1. We write Θ ⊢ A to indicate thatype Variables X, Y
Term Variables x, y
Type Contexts Θ ::= · | Θ , X Types
A, B ::= X | A + B | A × B | A → B | µX.A Term Contexts Γ ::= · | Γ , x : A Terms
M, N ::= x | ( M, N ) | π M | π M | in M | in M | ( case M of in x ⇒ N | in y ⇒ N ) | λx.M | M N | fold M | unfold M | M or p N Values
V, W ::= x | ( V, W ) | in V | in V | fold V | λx.M Fig. 1. Grammars for types, contexts and terms. Θ ⊢ Θ ⊢ Θ i Θ ⊢ A Θ ⊢ B ⋆ ∈ { + , × , →} Θ ⊢ A ⋆ B Θ , X ⊢ A Θ ⊢ µX.A Fig. 2. Formation rules for types. Γ , x : A ⊢ x : A Γ ⊢ M : A Γ ⊢ N : A Γ ⊢ M or p N : A Γ ⊢ M : A Γ ⊢ N : B Γ ⊢ ( M, N ) : A × B Γ ⊢ M : A × A i ∈ { , } Γ ⊢ π i M : A i Γ ⊢ M : A i i ∈ { , } Γ ⊢ in i M : A + A Γ ⊢ M : A + A Γ , x : A ⊢ N : B Γ , y : A ⊢ N : B Γ ⊢ ( case M of in x ⇒ N | in y ⇒ N ) : B Γ , x : A ⊢ M : B Γ ⊢ λx A .M : A → B Γ ⊢ M : A → B Γ ⊢ N : A Γ ⊢ M N : B Γ ⊢ M : A [ µX.A/X ]Γ ⊢ fold M : µX.A Γ ⊢ M : µX.A Γ ⊢ unfold M : A [ µX.A/X ] Fig. 3. Formation rules for terms. All types are assumed to be closed and well-formed. π ( V, W ) −→ V π ( V, W ) −→ W ( case in V of in x ⇒ N | in y ⇒ N ) −→ N [ V /x ]( case in V of in x ⇒ N | in y ⇒ N ) −→ N [ V /y ] unfold fold V −→ V ( λx.M ) V −→ M [ V /x ] M or p N p −→ M M or p N − p −−→ N E ::= [ · ] | ( E, M ) | ( V, E ) | π i E | EM | V E | in i E | ( case E of in x ⇒ N | in y ⇒ N ) | fold E | unfold EM p −→ M ′ E [ M ] p −→ E [ M ′ ] Fig. 4. Reduction rules for
PFPC . The grammar for E defines our call-by-value evaluation contexts. type A is well-formed in type context Θ whenever the judgement is derivable via the rules in Figure 2. A type A is closed when · ⊢ A . We remark that there are no restrictions on the admissible logical polarities of our type expressions, even whenforming recursive types. Example 1.
Some important (closed) types may be defined in the following way. The empty type is defined as def = µX.X and the unit type as def = 0 → . We may also define: • Booleans as Bool def = 1 + 1 ; • Natural numbers as Nat def = µX. X ; • Lists of type A as List ( A ) def = µX. A × X ; • Streams of type A as Stream ( A ) def = µX. → A × X ;and many others. B. The Terms of
PFPC
We now explain the syntax we use for terms. When forming terms and term contexts, we implicitly assume that all typeswithin are closed and well-formed. We use x, y to range over term variables and we use Γ to range over term contexts . A(well-formed) term context Γ = x : A , . . . , x n : A n is a list of (distinct) variables with their types. The terms (ranged overby M, N ) and the values (ranged over by
V, W ) of
PFPC are specified in Figure 1 and their formation rules in Figure 3. Theyre completely standard. In Figure 3, the notation A [ µX.A/X ] indicates type substitution which is defined in the standardway. The term M or p N represents probabilistic choice. A term M of type A is closed when · ⊢ M : A and in this case wealso simply write M : A. Example 2.
Important closed values in
PFPC include: the unit value () def = λx .x : 1; the false and true values given by ff def = in () : Bool and tt def = in () : Bool ; the zero natural number zero def = fold in () : Nat and the successor function succ def = λn Nat . fold in n : Nat → Nat ; among many others. C. The Reduction Rules of
PFPC
To describe execution of programs in
PFPC , we use a small-step call-by-value operational semantics which is described inFigure 4. The reduction relation M p −→ N should be understood as specifying that term M reduces to term N with probability p ∈ [0 , in exactly one step. Our reduction rules are simply the standard rules for small-step reduction in FPC [32, §20] andsmall-step reduction for probabilistic choice [33]. Of course, it is well-known this system is type-safe.
Theorem 3. If Γ ⊢ M : A and M p −→ N, then Γ ⊢ N : A. In this situation, if p < , then there exists a term N ′ , such that M − p −−→ N ′ . Furthermore, if · ⊢ M : A , then either M is a value or there exists N, such that M p −→ N for some p ∈ [0 , . Assumption 4.
Throughout the rest of the paper, we implicitly assume that all types, terms and contexts are well-formed.
D. Recursion and Asymptotic Behaviour of Reduction
It is well-known that type recursion in
FPC induces term recursion [29], [30], [32] and the same is true for
PFPC . This allowsus to derive the call-by-value fixpoint operator · ⊢ fix A → B : (( A → B ) → A → B ) → A → B at any function type A → B (see [29] and [30, §8] for more details). Using fix A → B , we may write recursive functions. Example 5.
Consider the following program: coins def = fix → λf → .λx . case ( ff or . tt ) ofin z ⇒ () | in z ⇒ f x. It follows · ⊢ coins : 1 → . Evaluating at () shows that coins () performs a fair coin toss and depending on the outcome,either terminates to () or repeats the process again. We see that there is no upper bound on the number of coin tossesthis program would perform. On the other hand, it is easy to see that the probability coins () terminates to () is precisely P ∞ i =1 − i = 1 . The above simple example shows that a rigorous operational analysis of
PFPC has to consider the asymptotic behaviour ofterms under reduction. We do this by showing how to determine the probability that a term reduces to a value in any numberof steps. We will later see that this is crucial for proving our adequacy result (Theorem 55).We may determine the overall probability that a term M reduces to a value V in the same way as in [9]. The probabilityweight of a reduction path π = (cid:16) M p −→ · · · p n −→ M n (cid:17) is P ( π ) def = Q ni =1 p i . The probability that term M reduces to the value V in at most n steps is P ( M −→ ≤ n V ) def = X π ∈ Paths ≤ n ( M,V ) P ( π ) , where Paths ≤ n ( M, V ) is the set of all reduction paths from M to V of length at most n . The probability that term M reducesto value V (in any finite number of steps) is P ( M −→ ∗ V ) def = sup i P ( M −→ ≤ i V ) . Finally, the probability that term M terminates is denoted Halt( M ) and it is determined in the following way: Val( M ) def = { V | V is a value and P ( M −→ ∗ V ) > } (1) Halt( M ) def = X V ∈ Val( M ) P ( M −→ ∗ V ) . (2)Note that the sum in (2) is countably infinite, in general.III. C OMMUTATIVE M ONADS FOR P ROBABILITY
In this section we present a novel and general construction for probabilistic commutative monads on
DCPO and we useit to identify three such monads. . Domain-theoretic and Topological Preliminaries
A nonempty subset A of a partially ordered set ( poset ) D is directed if each pair of elements in A has an upper bound in A . A directed-complete partial order, ( dcpo , for short) is a poset in which every directed subset A has a supremum sup A .For example, the unit interval [0 , is a dcpo in the usual ordering. A function f : D → E between two (posets) dcpo’s is Scott-continuous if it is monotone and preserves (existing) suprema of directed subsets.The category
DCPO of dcpo’s and Scott-continuous functions is complete, cocomplete and cartesian closed [34]. Wedenote with A × A ( A + A ) the categorical (co)product of the dcpo’s A and A and with π , π ( in , in ) the associated(co)projections. We denote with ∅ and the initial and terminal objects of DCPO ; these are the empty dcpo and the singletondcpo, respectively.
DCPO is Cartesian closed, where the internal hom of A and B is [ A → B ] , the Scott-continuous functions f : A → B ordered pointwise.The category DCPO ⊥ ! of pointed dcpo’s and strict Scott-continuous functions also is important.
DCPO ⊥ ! is symmetricmonoidal closed when equipped with the smash product and strict Scott-continuous function space, and it is also completeand cocomplete [34].The Scott topology σD on a dcpo D consists of the upper subsets U = ↑ U = { x ∈ D | ( ∃ u ∈ U ) u ≤ x } that are inaccessible by directed suprema: i.e., if A ⊆ D is directed and sup A ∈ U , then A ∩ U = ∅ . The space ( D, σD ) is alsowritten as Σ D . Scott-continuous functions between dcpo’s D and E are exactly the continuous functions between Σ D and Σ E [35, Proposition II-2.1]. We always equip [0 , with the Scott topology unless stated otherwise.A subset B of a dcpo D is a sub-dcpo if every directed subset A ⊆ B satisfies sup D A ∈ B . In this case, B is a dcpoin the induced order from D . The d-topology on D is the topology whose closed subsets consist of sub-dcpo’s of D . Open(closed) sets in the d-topology will be called d-open (d-closed) . The d-closure of C ⊆ D is the topological closure of C withrespect to the d-topology on D , which is the intersection of all sub-dcpo’s of D containing C .The family of open sets of a topological space X , denoted O X , is a complete lattice in the inclusion order. The specializationorder ≤ X on X is defined as x ≤ X y if and only if x is in the closure of { y } , for x, y ∈ X . We write Ω X to denote X equipped with the specialization order. It is well-known that X is T if and only if Ω X is a poset. A subset of X is called saturated if it is an upper set in Ω X . A space X is called a d-space or a monotone-convergence space if Ω X is a dcpo andeach open set of X is Scott open in Ω X . As an example, Σ D is always a d-space for each dcpo D . The full subcategoryof T consisting of d-spaces is denoted by D . There is a functor Σ :
DCPO → D that assigns the space Σ D to each dcpo D , and the map f : Σ D → Σ E to the Scott-continuous map f : D → E . Dually, the functor Ω : D → DCPO assigns Ω X to each d-space X and the map f : Ω X → Ω Y to each continuous map f : X → Y . In fact, Σ ⊣ Ω , i.e., Σ is left adjoint to Ω [36].A T space X is called sober if every nonempty closed irreducible subset of X is the closure of some (unique) singletonset, where A ⊆ X is irreducible if A ⊆ B ∪ C with B and C nonempty closed subsets implies A ⊆ B or A ⊆ C . Thecategory of sober spaces and continuous functions is denoted by SOB . Sober spaces are d-spaces, hence
SOB ⊆ D [14]. B. A Commutative Monad for Probability
To begin, a subprobability valuation on a topological space X is a Scott-continuous function ν : O X → [0 , that is strict( ν ( ∅ ) = 0 ), and modular ( ν ( U ) + ν ( V ) = ν ( U ∪ V ) + ν ( U ∩ V )) . The set of subprobability valuations on X is denoted by V X . The stochastic order on V X is defined pointwise: ν ≤ ν if and only if ν ( U ) ≤ ν ( U ) for all U ∈ O X . V X is apointed dcpo in the stochastic order, with least element given by the constantly zero valuation X and where the supremumof a directed family { ν i } i ∈ I is sup i ∈ I ν i def = λU. sup i ∈ I ν i ( U ) .The canonical examples of subprobability valuations are the Dirac valuations δ x for x ∈ X , defined by δ x ( U ) = 1 if x ∈ U and δ x ( U ) = 0 otherwise. V X enjoys a convex structure: if ν i ∈ V X and r i ≥ , with P ni =1 r i ≤ , then the convex sum P ni =1 r i ν i def = λU. P ni =1 r i ν i ( U ) also is in V X . The simple valuations on D are those of the form P ni =1 r i δ x i , where x i ∈ X , r i > , i = 1 , . . . , n and P ni =1 r i ≤ . The set of simple valuations on X is denoted by S X . Clearly, S X ⊆ V X . Unlike V X , S X is not directed-complete in the stochastic order in general.Given ν ∈ V X and f : X → [0 , continuous, we can define the integral of f against ν by the Choquet formula Z x ∈ X f ( x ) dν def = Z ν ( f − (( t, dt, where the right side is a Riemann integral of the bounded antitone function λt.ν ( f − (( t, . If no confusion occurs, wesimply write R x ∈ X f ( x ) dν as R f dν . Basic properties of this integral can be found in [12]. Here we note that the map ν R f dν : V X → [0 , , for a fixed f , is Scott-continuous, and Z f d n X i r i δ x i = n X i =1 r i f ( x i ) (3)or P ni =1 r i δ x i ∈ V X .For a dcpo D , V D is defined as V ( D, σD ) . Using Manes’ description of monads (Kleisli triples) [37], Jones proved in herPhD thesis [12] that V is a monad on DCPO : • The unit of V at D is η V D : D → V D : x δ x . • The
Kleisli extension f † of a Scott-continuous map f : D → V E maps ν ∈ V D to f † ( ν ) ∈ V E by f † ( ν ) def = λU ∈ σE. R x ∈ D f ( x )( U ) dν. Then the multiplication µ V D : VV D → V D is given by id †V D ; it maps ̟ ∈ VV D to λU ∈ σD. R ν ∈V D ν ( U ) d̟ ∈ V D . Thus, V defines an endofunctor on DCPO that sends a dcpo D to V D , and a Scott-continuous map h : D → E to V ( h ) def = ( η E ◦ h ) † ;concretely, V ( h ) maps ν ∈ V D to λU ∈ σE.ν ( h − ( U )) .Jones [12] also showed that V is a strong monad over DCPO : its strength at ( D, E ) is given by τ V DE : D × V E → V ( D × E ) : ( x, ν ) λU. Z y ∈ E χ U ( x, y ) dν, where χ U is the characteristic function of U ∈ σ ( D × E ) . Whether V is a commutative monad on DCPO has remained anopen problem for decades. Proving this to be true requires showing the following Fubini-type equation holds: Z x ∈ D Z y ∈ E χ U ( x, y ) dξdν = Z y ∈ E Z x ∈ D χ U ( x, y ) dνdξ, (4)for dcpo’s D and E , for U ∈ σ ( D × E ) and for ν ∈ V D, ξ ∈ V E [11, Section 6]. The difficulty lies in the well-known factthat a Scott open set U ∈ σ ( D × E ) might not be open in the product topology σD × σE in general [35, Exercise II-4.26].However, if either ν or ξ is a simple valuation, then Equation (4) holds. For example, if ν = P ni =1 r i δ x i ∈ S D , then by (3)both sides of (4) are equal to P ni =1 r i R y ∈ E χ U ( x i , y ) dξ . The Scott continuity of the integral in ν then implies Equation (4)holds for valuations that are directed suprema of simple valuations. This is why, for example, V is a commutative monad onthe category of domains and Scott-continuous maps, as we now explain.If D is a dcpo and x, y ∈ D , we say x is way-below y (in symbols, x ≪ y ) if and only if for every directed set A with y ≤ sup A , there is some a ∈ A such that x ≤ a . We write ↓↓ y = { x ∈ D | x ≪ y } . A basis for a dcpo D is subset B satisfying ↓↓ x ∩ B is directed and x = sup ↓↓ x ∩ B , for each x ∈ D . D is continuous if it has a basis. Continuous dcpo’s arealso called domains , and the category of domains and Scott-continuous maps is denoted by DOM .Applying the reasoning above about simple valuations, we obtain a commutative monad of valuations on
DCPO byrestricting to a suitable completion of S D inside V D . There are several possibilities (cf. [21]), and we choose the smallestand simplest – the d-closure of S D in V D . Definition 6.
For each dcpo D , we define M D to be the intersection of all sub-dcpo’s of V D that contain S D . Since V D itself is a dcpo containing S D , it is immediate from the definition of sub-dcpo’s that M D is a well-defined dcpoin the stochastic order with S D ⊆ M D ⊆ V D . Analogous to V D , M D also enjoys a convex structure. Lemma 7.
For ν i ∈ M D and r i ≥ , i = 1 , . . . , n with P ni =1 r i ≤ , the convex sum P ni =1 r i ν i is still in M D .Proof. In Appendix A.For the proofs of the following results, we repeatedly use the fact that Scott-continuous maps between dcpo’s D and E are d-continuous , i.e., continuous when D and E are equipped with the d-topology [38, Lemma 5]. Theorem 8. M is a commutative monad on DCPO .Proof.
We sketch the key steps in showing M is commutative: Unit : The unit of M at D is η M D : D → M D : x δ x , the co-restriction of η V D to M D . Obviously, it is a well-definedScott-continuous map. Extension : Since a Scott-continuous map f : D → M E is also Scott-continuous from D to V E , the Kleisli extension f ‡ : M D → M E of f can be defined as the restriction and co-restriction of f † : V D → V E to M D and M E , respectively.The validity of this definition requires f † ( M D ) ⊆ M E , which boils down to f † ( S D ) ⊆ M E by d-continuity of f † , since f † is Scott-continuous. Hence we only need to check that f † ( P ni =1 r i δ x i ) ∈ M E for each P ni =1 r i δ x i ∈ S D . However, f † ( P ni =1 r i δ x i ) = P ni =1 r i f ( x i ) , which is indeed in M E by Lemma 7. The same definition applies in the case of topological spaces. trength : The strength τ M DE of M at ( D, E ) is given by τ V DE restricted to D × M E and co-restricted to M ( D × E ) .This is well-defined provided that τ V DE maps D × M E into M ( D × E ) . Again, we only need to prove that τ V DE maps D × S E into M ( D × E ) and conclude the proof with the d-continuity of τ V DE in its second component. Towards this end, we pick ( a, P ni =1 r i δ y i ) ∈ D × S E , and see τ V DE ( a, n X i =1 r i δ y i ) = λU. Z χ U ( a, y ) d n X i =1 r i δ y i (3) = λU. n X i =1 r i χ U ( a, y i )= λU. n X i =1 r i δ ( a,y i ) ( U ) def = n X i =1 r i δ ( a,y i ) is indeed in M ( D × E ) .With f ‡ and τ M well-defined, the same arguments used to prove ( V , η V , _ † , τ V ) is a strong monad in [12] prove ( M , η M , _ ‡ , τ M ) is a strong monad on DCPO . Commutativity : Finally, we show M is commutative by proving the Equation (4) holds for any dcpo’s D and E and ν ∈ M D, ξ ∈ M E . As commented above, this holds if ν is simple, and then the Scott-continuity of the integral in the ν -component implies Equation (4) also holds for directed suprema of simple valuations, directed suprema of directed supremaof simple valuations and so forth, transfinitely. But these are exactly the valuations M D .Formally, we consider for each fixed ξ ∈ M E (even for ξ ∈ V E ) the functions F : ν Z x ∈ D Z y ∈ E χ U ( x, y ) dξdν : M D → [0 , and G : ν Z y ∈ E Z x ∈ D χ U ( x, y ) dνdξ : M D → [0 , . Note that both F and G are Scott-continuous functions hence d-continuous, and they are equal on S D by Equation (3). Since [0 , is Hausdorff in the d-topology, F and G are then equal on the d-closure of S D which is, by construction, M D . Remark . The multiplication µ M D of M at D is given by (id M D ) ‡ . Concretely, µ M D maps each valuation ̟ ∈ M ( M D ) to λU ∈ σD. R ν ∈M D ν ( U ) d̟ . In particular, µ M D maps each simple valuation P ni =1 r i δ ν i ∈ M ( M D ) to P ni =1 r i ν i , where ν i ∈ M D, i = 1 , . . . , n , and P ni =1 r i ≤ . Remark . The double strength of M at ( D, E ) is given by the Scott-continuous map ( ν, ξ ) ν ⊗ ξ : M ( D ) × M ( E ) →M ( D × E ) , where ν ⊗ ξ is defined as λU ∈ σ ( D × E ) . R y ∈ E R x ∈ D χ U ( x, y ) dνdξ . Remark . We note that M D is the first example of a commutative valuations monad on DCPO that contains the simplevaluations. And, since every valuation on a domain D is a directed supremum of simple valuations [12, Theorem 5.2], itfollows that M = V on the category DOM . C. Dcpo-completion versus D -completion Recall that a dcpo-completion of a poset P is a pair ( D, e ) , where D is a dcpo and e : P → D is an injective Scott-continuousmap, such that for any dcpo E and Scott-continuous map f : P → E , there exists a unique Scott-continuous map f ′ : D → E satisfying f = f ′ ◦ e . The dcpo-completion of posets always exists [38, Theorem 1].As we have seen, for each dcpo D , M D is the smallest sub-dcpo in V D containing S D , one may wonder whether M D ,together with the inclusion map from S D into M D , is a dcpo-completion of S D . The answer is “no” in general. Thereason is that the inclusion of S D into M D may not be Scott-continuous, even when D is a domain (see [21, Section 6]). Theconstruction M D is actually more in a topological flavour, as we now explain. For simplicity, we assume all spaces consideredin the sequel are in T , the category of T spaces and continuous maps. Definition 12.
Let X be a topological space. The weak topology on V X is generated by the sets [ U > r ] def = { ν ∈ V X | ν ( U ) > r } , which form a subbasis, where U is open in X and r ∈ [0 , . Remark . For each continuous map f : X → [0 , and r ∈ [0 , , the set [ f > r ] def = { ν ∈ V X | R f dν > r } is open in theweak topology.e use V w X to denote the space V X equipped with the weak topology. We will use the fact that V w X is a sober space,which follows from [39, Proposition 5.1]. It is easy to see that the specialization order on V w X is just the stochastic order.Hence V X = Ω( V w X ) .We also use S w X ( M w X ) to denote the space S X ( M X ) endowed with the relative topology from V w X . Accordingly, M X = Ω( M w X ) , and S X = Ω( S w X ) . Although M X is not the dcpo-completion of S X in general, we do have thefollowing: Proposition 14.
For each space X , M w X is a D -completion of S w X . That is, M w X itself is a d-space, an object in D ;the inclusion map i : S w X → M w X is continuous; and for any d-space Y and continuous map f : S w X → Y , there exists aunique continuous map f ′ : M w X → Y such that f = f ′ ◦ i . The above proposition is a straightforward application of Keimel and Lawson’s K -category theory [14] to the category D . Definition 15. A K -category K is a full subcategory of T , whose objects will be called k-spaces, satisfying:1) Homeomorphic copies of k-spaces are k-spaces;2) All sober spaces are k-spaces, i.e., SOB ⊆ K ;3) In a sober space S , the intersection of any family of k-subspaces, equipped with the relative topology from S , is ak-space;4) For any continuous map f : S → T between sober spaces S and T , and any k-subspace K of T , f − ( K ) is k-subspaceof S .If K is a K -category, then the K -completion of any T -space X always exists, and one possible completion process goesas follows [14, Theorem 4.4]: First, pick any j : X → Y such that Y is sober and j is a topological embedding. For example,one can take j as the embedding of X into its standard sobrification. Second, let ˜ X be the intersection of all k-subspaces of Y containing j ( X ) and equip it with the relative topology from Y . Then ˜ X , together with the co-restriction i : X → ˜ X of j ,is a K -completion of X .Now we apply this procedure to prove Proposition 14. First, note that D is indeed a K -category as proved in [14, Lemma6.4]. We embed S w X into the sober space V w X , and notice that all d-subspaces of V w X are precisely sub-dcpo’s of V X .Hence M w X , which is the intersection of sub-dcpo’s V X containing S X equipped with the relative topology from V w X , isa D -completion of S w X . D. A uniform construction
Proposition 14 motivates the next definition.
Definition 16.
Let K be a K -category. For each space X , we define V K X to be the intersection of all k-subspaces of V w X containing S w X , equipped with the relative topology from V w X .As discussed above, V K X is a K -completion of S w X . It was proved in [21, Theorem 3.5] that V K : T → T is a monadfor each K -category K : The unit of V K at X maps x ∈ X to δ x , and for any continuous map f : X → V K Y , the Kleisliextension f † : V K X → V K Y maps ν to λU ∈ O Y. R x ∈ X f ( x )( U ) dν . Therefore, if K is a full subcategory of D , then accordingto the construction V K X is always a d-space for each X , hence the monad V K : T → T can be restricted to a monad on D . Theorem 17.
Let K be a K -category with K ⊆ D . Then V K , ≤ def = Ω ◦ V K ◦ Σ is a monad on DCPO . DCPO D D V K Σ FV K Ω ⊣ U ⊣ Proof.
Let D V K be the Eilenberg-Moore category of V K over D and F ⊣ U be the adjunction that recovers V K , then V K , ≤ = Ω ◦ U ◦ F ◦ Σ . The statements follow from the standard categorical fact that adjoints compose: F ◦ Σ ⊣ Ω ◦ U . Remark . The unit of V K , ≤ at dcpo D sends x ∈ D to δ x , and for dcpo’s D and E , the Kleisli extension f † : V K , ≤ D →V K , ≤ E of f : D → V K , ≤ E maps ν to λU ∈ σE. R x ∈ D f ( x )( U ) dν . Remark . M w = V D and M = V D , ≤ .Note that the category SOB of sober spaces is the smallest K -category [14, Remark 4.1]. We denote V SOB by P w and V SOB , ≤ by P . The following statement is then obvious. The definition of K -completion is similar to that of D -completion and can be found in [14]. The authors allow valuations to take values in [0 , ∞ ] . However, the theorem is also true for valuations with values in [0 , roposition 20. Let K be a K -category with K ⊆ D . Then for each dcpo D , we have S D ⊆ M D ⊆ V K , ≤ D ⊆ P D ⊆ V D . Heckmann [39, Theorem 5.5] proved that P D consists of the so-called point-continuous valuations on D . We claim thatthe Equation 4 holds when either ν or ξ is point-continuous: Theorem 21.
Let D and E be dcpo’s, and U ∈ σ ( D × E ) . Then the equation Z x ∈ D Z y ∈ E χ U ( x, y ) dξdν = Z y ∈ E Z x ∈ D χ U ( x, y ) dνdξ, holds for ( ν, ξ ) ∈ P D × V E (equivalently, ( ν, ξ ) ∈ V D × P E ). As far as we know, this is the most general Fubini theorem on dcpo’s. The proof, which relies on the Schröder-SimpsonTheorem [40], is included in Appendix A. Hence by combining Remark 18, Proposition 20 and Theorem 21 we get our nexttheorem.
Theorem 22.
For any K -category K with K ⊆ D , V K , ≤ is a commutative monad on DCPO .Proof.
In Appendix A.As promised, we conclude this subsection with a third commutative monad W on DCPO by describing a K -category lyingbetween SOB and D , the category WF consisting of well-filtered spaces and continuous maps. A T space X is well-filtered if, given any filtered family { K a } a ∈ A of compact saturated subsets of X with T a ∈ A K a ⊆ U , with U open, there is some a ∈ A with K a ⊆ U . A proof that WF is a K -category between SOB and D can be found in [41]. Hence W def = V WF , ≤ is acommutative monad on DCPO and M D ⊆ W D ⊆ P D for every dcpo D . Remark . All subsequent results we present in this paper hold for the three monads M , W and P . To avoid cumbersomerepetition, we explicitly state them for M . E. Continuous Kegelspitzen and M -algebras Kegelspitzen [15] are dcpo’s that enjoy a convex structure. In this section, we show every continuous
Kegelspitze K hasa linear barycenter map β : M K → K making ( K, β ) an M -algebra and conversely, every M -algebra ( K, β ) on DCPO admits a Kegelspitze structure on K making β : M K → K a linear map. We begin with the notion of a barycentric algebra. Definition 24. A barycentric algebra is a set A endowed with a binary operation a + r b for every real number r ∈ [0 , suchthat for all a, b, c ∈ A and r, p ∈ [0 , , the following equations hold: a + b = a ; a + r b = b + − r a ; a + r a = a ;( a + p b ) + r c = a + pr ( b + r − pr − pr c ) provided r, p < . Definition 25. A pointed barycentric algebra is a barycentric algebra A with a distinguished element ⊥ . For a ∈ A and r ∈ [0 , , we define r · a def = a + r ⊥ . A map f : A → B between pointed barycentric algebras is called linear if f ( ⊥ A ) = ⊥ B and f ( a + r b ) = f ( a ) + r f ( b ) for all a, b ∈ A, r ∈ [0 , . Definition 26. A Kegelspitze is a pointed barycentric algebra K equipped with a directed-complete partial order such that,for every r in the unit interval, the functions determined by convex combination ( a, b ) a + r b : K × K → K and scalarmultiplication ( r, a ) r · a : [0 , × K → K are Scott-continuous in both arguments. A continuous Kegelspitze is a Kegelspitzethat is a domain in the equipped order. Remark . In a Kegelspitze K , the map ( r, a ) r · a = a + r ⊥ is Scott-continuous, hence monotone, in the r -component,which implies ⊥ = ⊥ + a = a + ⊥ = 0 · a ≤ · a = a for each a ∈ K , i.e., ⊥ is the least element of K . Example 28.
For each dcpo D , M D is a Kegelspitze: for ν , ν ∈ M D and r ∈ [0 , , ν + r ν is defined as rν + (1 − r ) ν .Lemma 7 implies this is well-defined. The constantly zero valuation D is the distinguished element. Verifying that M D isa Kegelspitze is then straightforward.As a consequence, for each Scott-continuous map f : D → E , the map M ( f ) : M D → M E : ν λU ∈ σE.ν ( f − ( U )) isobviously linear. Definition 29.
In each pointed barycentric algebra K , for a i ∈ K, r i ∈ [0 , , i = 1 , . . . , n with P ni =1 r i ≤ , we define theconvex sum inductively n X i =1 r i a i def = ( a , if r = 1 ,a + r ( P ni =2 r i − r a i ) , if r < . Note that Lemma 7 is stated only for M , but it also holds for W and P : one notes that ν rν + (1 − r ) ν : V w D → V w D is a continuous mapbetween sober spaces and then uses Definition 15 Item (4) to replace “d-continuity” in the proof. his is invariant under index-permutation: for π a permutation of { , . . . , n } , P ni =1 r i a i = P ni =1 r π ( i ) a π ( i ) [12, Lemma 5.6]. If K is a Kegelspitze, then the expression P ni =1 r i a i is Scott-continuous in each r i and a i . A countable convex sum may also bedefined: given a i ∈ K and r i ∈ [0 , , for i ∈ I , with P i ∈ I r i ≤ , let P i ∈ I r i a i def = sup { P j ∈ J r j a j | J ⊆ I and J is finite } . Lemma 30.
A function f : K → K between pointed barycentric algebras K and K is linear if and only if f ( P ni =1 r i a i ) = P ni =1 r i f ( a i ) for a i ∈ K , i = 1 , . . . , n and P ni =1 r i ≤ . Definition 31.
Let K be a Kegelspitze and s = P ni =1 r i δ x i be a simple valuation on K . The barycenter of s is defined as β ∗ ( s ) def = P ni =1 r i x i .As a straightforward consequence of Jones’ Splitting Lemma ( [35, Proposition IV-9.18]), the map β ∗ ( s ) is monotone from S K to K . If K is continuous, then M K = V K and S K is a basis for M K (see Remark 11). We extend β ∗ to the barycentermap β : M K → K by β ( ν ) def = sup { β ∗ ( s ) | s ∈ S K and s ≪ ν } . Note that for each simple valuation s = P ni =1 r i δ x i ∈ S K , there exists a directed set A of S K with supremum s consistingof simple valuations way-below s . For example, one can choose A = { P ni =1 mr i m +1 δ y i | m ∈ N and y i ≪ x i } . By [35, LemmaIV-9.23.], the map β , as defined above, is a Scott-continuous map extending β ∗ , i.e., β ( ν ) = β ∗ ( ν ) for ν ∈ S K . Moreover, β is a linear map since β ∗ is. Proposition 32.
Each continuous
Kegelspitze K admits a linear barycenter map β : M K → K (as above) for which the pair ( K, β ) is an Eilenberg-Moore algebra of M .Proof. Clearly, β ◦ η M K = id K . To prove that β ◦ µ M K = β ◦ M ( β ) , we only need to prove both sides are equal on simplevaluations in M ( M K ) , since S ( M K ) is dense in M ( M K ) in the d-topology, and both sides of the equation are d-continuousfunctions. However, when applied to the simple valuation P ni =1 r i δ ν i ∈ S ( M K ) , both sides equal P ni =1 r i β ( ν i ) . This followsfrom direct computation by employing Remark 9 and linearity of β .We next show that every Eilenberg-Moore algebra ( K, β ) of M on DCPO admits a Kegelspitze structure on K making β : M K → K a linear map. Proposition 33.
Let ( K, β ) be an M -algebra on DCPO . For a, b ∈ K and r ∈ [0 , , define a + r b def = β ( δ a + r δ b ) . Thenwith the operation + r , K is a Kegelspitze and β : M K → K is linear.Proof. See Appendix A.
Proposition 34.
Let ( K , β ) and ( K , β ) be M -algebras on DOM . A Scott-continuous function f : K → K is an algebramorphism from ( K , β ) to ( K , β ) if and only if f is linear with respect to the Kegelspitze structure on K and K introducedby β and β , respectively, as in Proposition 33.Proof. See Appendix A.
Theorem 35.
The Eilenberg-Moore category
DOM M of M over DOM is isomorphic to the category of continuousKegelspitzen and Scott-continuous linear maps.Proof.
Combine Propositions 32, 33 and 34.
Remark . Theorem 35 characterises
DOM M , which equals DOM V K , ≤ for any K -category K with K ⊆ D since V = M on domains (see Remark 11 and Proposition 20). This corrects an error in [12]: there it is proved that continuous abstractprobabilistic domains and linear maps form a full subcategory of DOM V . But there is a claim that all objects in DOM V are abstract probabilistic domains. A separating example is the extended non-negative reals [0 , ∞ ] , which is a continuousKegelspitze but not an abstract probabilistic domain.IV. C ATEGORICAL M ODEL
In this section we describe the categorical properties of the Kleisli category of our monad M . Everything we say in thissection is also true for our other two monads as well.We write DCPO M for the Kleisli category of our monad M : DCPO → DCPO . In order to distinguish between thecategorical primitives of
DCPO and
DCPO M , we indicate with f : A . → B the morphisms of DCPO M and we write f (cid:18) g def = µ ◦M ( f ) ◦ g for the Kleisli composition of morphisms in DCPO M . We write id A : A . → A with id A = η A : A → M A for the identity morphisms in DCPO M . The monad M induces an adjunction J ⊣ U : DCPO M → DCPO , where: J A def = A, J f def = η ◦ f, U A def = M A, U f def = µ ◦ M f. ) Coproducts: The category
DCPO M inherits (small) coproducts from DCPO in the standard way [42, pp. 264] and wewrite A . + A def = A + A for the induced (binary) coproduct. The induced coprojections are given by J ( in ) : A . → A . + A and J ( in ) : A . → A . + A . Then for f : A . → C and g : B . → D , f . + g = [ M ( in C ) ◦ f, M ( in D ) ◦ g ] .
2) Symmetric monoidal structure:
Because our monad M is commutative , it induces a symmetric monoidal structure on DCPO M in a canonical way [43, pp. 462]. The induced tensor product is A . × B def = A × B and the Kleisli projectionsare J ( π A ) : A . × B . → A and J ( π B ) : A . × B . → B . For f : A . → C and g : B . → D , their tensor product is given by f . × g = λ ( a, b ) .f ( a ) ⊗ g ( b ) . Note that the last expression uses the double strength of M , see Remark 10.Standard categorical arguments now show that the Kleisli products distribute over the Kleisli coproducts. We write d A,B,C : A . × ( B . + C ) ∼ = ( A . × B ) . + ( A . × C ) for this natural isomorphism.
3) The left adjoint J : The functor J , whose action is the identity on objects, preserves the monoidal structure and thecoproduct structure up to equality (and not merely up to isomorphism). That is, J ( A ⋆ B ) = JA . ⋆ JB and J ( f ⋆ g ) = Jf . ⋆ Jg, where ⋆ ∈ {× , + } .
4) Kleisli Exponential:
Our Kleisli adjunction also contains the structure of a
Kleisli-exponential (which is also known asa M -exponential ). Following Moggi [17], we will use this to interpret higher-order function types. Next, we describe thisstructure in greater detail.The functor J ( − ) . × B : DCPO → DCPO M has a right adjoint, which we write as [ B . → − ] : DCPO M → DCPO , for each dcpo B . In particular [ B . → − ] def = [ B → U ( − )] , which means that, on objects, [ B . → C ] = [ B → M C ] . This dataprovides us with a family of Scott-continuous bijections λ : DCPO M ( J A . × B, C ) ∼ = DCPO ( A, [ B . → C ]) (5)natural in A and C , called currying . We also denote with ǫ : J [ B . → − ] . × B ⇒ Id , the counit of the adjunctions (5), oftencalled evaluation . Because this family of adjunctions is parameterised by objects B of DCPO M , it follows using standardcategorical results [44, §IV.7] that the assignment [ B . → − ] : DCPO M → DCPO may be extended uniquely to a bifunctor [ − . → − ] : DCPO op M × DCPO M → DCPO , such that the bijections λ in (5) are natural in all components . Remark . Some authors describe currying and evaluation for Kleisli exponentials without referring to the functor J . Thiscannot lead to confusion on the object level, but to be fully precise, one has to specify that the naturality properties on the A -component hold only for total maps. We make this explicit by including J in our presentation.
5) Enrichment Structure:
The category
DCPO M is enriched over DCPO ⊥ ! : for all dcpo’s A, B and C , the Kleisliexponential [ A . → B ] = [ A → M B ] = DCPO M ( A, B ) is a pointed dcpo in the pointwise order, and the Kleisli composition (cid:18) : [ A . → B ] × [ B . → C ] → [ A . → C ] : ( f, g ) g (cid:18) f = g ‡ ◦ f is obviously a strict Scott-continuous map. Moreover, the adjunction J ⊣ U : DCPO M → DCPO is also
DCPO -enriched(see [45, Definition 6.7.1] for definition) and so are the bifunctors ( − . × − ) , ( − . + − ) and [ − . → − ] . We interpret probabilistic effects using the convex structure of our model which we now describe. For each dcpo B , M B is a Kegelspitze in the stochastic order (Example 28) : for r ∈ [0 , and ν , ν ∈ M B , ν + r ν is defined as rν + (1 − r ) ν ;the zero-valuation B is the distinguished element (which is also least). It follows that [ A . → B ] = DCPO M ( A, B ) is aKegelspitze in the pointwise order: for f, g ∈ [ A . → B ] , f + r g is defined as λx.f ( x ) + r g ( x ) . Next, we note that this convexstructure is preserved by Kleisli composition (cid:18) , Kleisli coproduct . + and Kleisli product . × . Lemma 38.
Let
A, B, C, D be dcpo’s, f, f , f ∈ [ A . → B ] , g, g , g ∈ [ B . → C ] , h, h , h ∈ [ C . → D ] and r ∈ [0 , . Then wehave: • ( g + r g ) (cid:18) f = g (cid:18) f + r g (cid:18) f ; • g (cid:18) ( f + r f ) = g (cid:18) f + r g (cid:18) f ; • ( f + r f ) . ⋆ h = f . ⋆ h + r f . ⋆ h ; • f . ⋆ ( h + r h ) = f . ⋆ h + r f . ⋆ h , where ⋆ ∈ {× , + } in the last two cases.Proof. See Appendix C.
6) Important Subcategories:
In order to describe our denotational semantics, we have to identify two important subcategoriesof
DCPO M . These projections do not satisfy the universal property of a product. This extension is canonically given by [ f . → g ] def = λ ( g (cid:18) ǫ C (cid:18) ( id . × f )) . efinition 39. The subcategory of deterministic total maps , denoted TD , is the full-on-objects subcategory of DCPO M eachof whose morphisms f : X . → Y admits a factorisation f = J ( f ′ ) = (cid:18) X f ′ −→ Y η Y −−→ M Y (cid:19) . Therefore, by definition, each map f : X . → Y in TD satisfies f ( x ) = δ y for some y ∈ Y . These maps are deterministic in the sense that they carry no interesting convex structure and they are total in the sense that they map all inputs x ∈ X tonon-zero valuations. The importance of this subcategory is that all values of our language admit an interpretation within TD .Moreover, the categorical structure of TD is very easy to describe, as our next proposition shows. Proposition 40.
There exists a
DCPO -enriched isomorphism of categories
DCPO ∼ = TD .Proof. Each map η X : X → M X is injective, because Σ X is a T space and so J : DCPO → DCPO M is faithful. Itscorestriction to TD is the required isomorphism.In our model, the canonical copy map at an object A is given by the map J h id A , id A i : A . → A . × A and the canonicaldiscarding map at A is the map J (1 A ) : A . → , where A : A → is the terminal map of DCPO . Because maps in TD are in the image of J , it follows that they are compatible with the copy and discard maps and thus also with weakening andcontraction [46], [47].The next subcategory we introduce is important, because we will use it for the interpretation of open types. It has sufficientstructure to solve recursive domain equations. Definition 41.
The subcategory of deterministic partial maps , denoted PD , is the full-on-objects subcategory of DCPO M each of whose morphisms f : X . → Y admits a factorisation f = (cid:18) X f ′ −→ Y ⊥ φ Y −−→ M Y (cid:19) , where Y ⊥ is the dcpo obtainedfrom Y by freely adding a least element ⊥ , and φ Y is the map: φ Y : Y ⊥ → M Y :: y ( Y , if y = ⊥ δ y , if y = ⊥ . These maps are partial because some inputs are mapped to , but also deterministic, because the convex structure is trivialin both cases. This is further justified by the next proposition. Proposition 42.
There exists a
DCPO ⊥ ! -enriched isomorphism of categories DCPO L ∼ = PD , where DCPO L is the Kleislicategory of the lift monad L : DCPO → DCPO .Proof.
The assignment φ from Definition 41 is a strong map of monads φ : L ⇒ M which then induces a functor F : DCPO L → DCPO M (Appendix B). Each φ Y is injective, so the corestriction of F to PD is the requiredisomorphism.
7) Solving Recursive Domain Equations:
In order to interpret recursive types, we solve the required recursive domainequations by constructing parameterised initial algebras [30], [31] within (the subcategory of embeddings of) PD using thelimit-colimit coincidence theorem [48]. Definition 43 (see [30, §6.1]) . Given a category C and a functor T : C n +1 → C , a parameterised initial algebra for T is apair ( T ♯ , ι T ) , such that: • T ♯ : C n → C is a functor; • ι T : T ◦ h Id , T ♯ i ⇒ T ♯ : C n → C is a natural transformation; • For every ~C ∈ Ob ( C n ) , the pair ( T ♯ ~C, ι T ~C ) is an initial T ( ~C, − ) -algebra.In the special case when n = 1 , we recover the usual notion of initial algebra. We consider parameterised initial algebrasbecause we need to interpret mutual type recursion. Similarly, one can also define the dual notion of parameterised finalcoalgebra . Proposition 44 (see [49, §4.3]) . Let C be a category with an initial object and all ω -colimits and let T : C n +1 → C be an ω -cocontinuous functor. Then T has a parameterised initial algebra ( T ♯ , ι T ) and the functor T ♯ : C n → C is also ω -cocontinuous. The next proposition shows that the subcategory PD has sufficient structure to solve recursive domain equations. Proposition 45.
The subcategory PD is (parameterised) DCPO -algebraically compact . More specifically, every
DCPO -enriched functor T : PD n +1 → PD has a parameterised compact algebra, i.e., a parameterised initial algebra whose inverseis a parameterised final coalgebra for T .roof. By Proposition 42, we have PD ∼ = DCPO L ∼ = DCPO ⊥ ! and the latter two categories are well-known to be DCPO -algebraically compact (which may be easily established using [30, Corollary 7.2.4]).Therefore, every
DCPO -enriched covariant functor on
DCPO M which restricts to PD can be equipped with aparameterised compact algebra. In order to solve equations involving mixed-variance functors (induced by function types),we use the limit-colimit coincidence theorem [48]. In particular, an important observation made by Smyth and Plotkin in [48]allows us to interpret all type expressions (including function spaces) as covariant functors on subcategories of embeddings .These ideas are developed in detail in [49], [50] and here we also follow this approach. Definition 46.
Given a
DCPO -enriched category C , an embedding of C is a morphism e : X → Y , such that there exists (anecessarily unique) morphism e p : Y → X , called a projection , with the properties: e p ◦ e = id X and e ◦ e p ≤ id Y . We denotewith C e the full-on-objects subcategory of C whose morphisms are the embeddings of C . Proposition 47.
The category PD e has an initial object and all ω -colimits, and the following assignments: • . × e : PD e × PD e → PD e by X . × e Y def = X . × Y and e . × e e def = e . × e . • . + e : PD e × PD e → PD e by X . + e Y def = X . + Y and e . + e e def = e . + e • [ . → ] J e : PD e × PD e → PD e [ X . → Y ] J e def = J [ X . → Y ] and [ e . → e ] J e def = J [ e p . → e ] define covariant ω -cocontinuous bifunctors on PD e .Proof. This follows using results from [48] together with some restriction arguments which we present in Appendix B.Therefore, by Proposition 44 and Proposition 47 we can solve recursive domain equations induced by all well-formed typeexpressions (with no restrictions on the admissible logical polarities of the types) within PD e . However, since our judgementssupport weakening and contraction, we have an extra proof obligation: showing each isomorphism that is a solution to arecursive domain equation can be copied and discarded. This is indeed true (for any isomorphism in PD ) because of the nextproposition. Proposition 48.
Every isomorphism of PD (and PD e ) is also an isomorphism of TD .Proof. In Appendix B.We have already explained that morphisms of TD are compatible with weakening and contraction, so the above propositionsuffices for our purposes. V. D ENOTATIONAL S EMANTICS
We now give the denotational semantics of our language by using ideas from [49], [50].
A. Interpretation of Types
We begin with the interpretation of (open) types. Every type Θ ⊢ A is interpreted as a functor J Θ ⊢ A K : PD | Θ | e → PD e and its interpretation is defined by induction on the derivation of Θ ⊢ A in Figure 5. The validity of this definition is justifiedby the next proposition. Proposition 49.
The assignments J Θ ⊢ A K : PD | Θ | e → PD e are ω -cocontinuous functors.Proof. By induction using Propositions 44 and 47.We are primarily interested in closed types and for them we simply write J A K def = J · ⊢ A K ( ∗ ) , where ∗ is the unique objectof the terminal category = PD e . For closed types, it follows that J A K ∈ Ob ( PD e ) = Ob ( DCPO ) .We proceed by defining the folding/unfolding isomorphisms for recursive types and proving a necessary lemma. Lemma 50 (Substitution) . If Θ , X ⊢ A and Θ ⊢ B , then: J Θ ⊢ A [ B/X ] K = J Θ , X ⊢ A K ◦ h Id , J Θ ⊢ B K i . Definition 51.
For closed types µX.A , we define: fold µX.A : J A [ µX.A/X ] K = J X ⊢ A KJ µX.A K ∼ = J µX.A K , Θ ⊢ A K : PD | Θ | e → PD e J Θ ⊢ Θ i K def = Π i J Θ ⊢ A + B K def = . + e ◦ h J Θ ⊢ A K , J Θ ⊢ B K i J Θ ⊢ A × B K def = . × e ◦ h J Θ ⊢ A K , J Θ ⊢ B K i J Θ ⊢ A → B K def = [ . → ] J e ◦ h J Θ ⊢ A K , J Θ ⊢ B K i J Θ ⊢ µX.A K def = J Θ , X ⊢ A K ♯ Fig. 5. Interpretation of types. J A × B K = J A K × J B KJ A + B K = J A K + J B KJ A → B K = [ J A K → M J B K ] J µX.A K ∼ = J A [ µX.A/X ] K Fig. 6. Derived equations for closed types. J Γ ⊢ M : A K : J Γ K . → J A K in DCPO M J Γ , x : A ⊢ x : A K def = J π J Γ ⊢ ( M, N ) : A × B K def = ( J M K . × J N K ) (cid:18) J h id , id i J Γ ⊢ π i M : A i K def = J π i (cid:18) J M K , for i ∈ { , } J Γ ⊢ in i M : A + A K def = J in i (cid:18) J M K , for i ∈ { , } J Γ ⊢ ( case M of in x ⇒ N | in y ⇒ N ) : B K def =[ J N K , J N K ] (cid:18) d (cid:18) (id . × J M K ) (cid:18) J h id , id i J Γ ⊢ λx A .M : A → B K def = J λ ( J M K ) J Γ ⊢ M N : B K def = ǫ (cid:18) ( J M K . × J N K ) (cid:18) J h id , id i J Γ ⊢ fold M : µX.A K def = fold (cid:18) J M KJ Γ ⊢ unfold M : A [ µX.A/X ] K def = unfold (cid:18) J M KJ Γ ⊢ M or p N : A K def = J M K + p J N K Fig. 7. Interpretation of term judgements. where the equality is Lemma 50 and the isomorphism is the initial algebra. We write unfold µX.A for the inverse isomorphism.Note that both of them are isomorphisms in TD .Now the equations for closed types in Figure 6 follow immediately. B. Interpretation of Terms
A context
Γ = x : A , . . . , x n : A n is interpreted as the dcpo J Γ K def = J A K × · · · × J A n K . A term Γ ⊢ M : A is, as usual,interpreted as a morphism J Γ ⊢ M : A K : J Γ K . → J A K in DCPO M and we will abbreviate this by writing J M K when its typeand context are clear. The interpretation of term judgements are defined by induction in Figure 7. This interpretation is definedin the standard categorical way using the structure of DCPO M and using the structure of the Kleisli exponential followingMoggi [17]. To interpret probabilistic choice, we use the convex structure of DCPO M . All the notation used in Figure 7 isintroduced in Section IV and Section V.
C. Soundness and Computational Adequacy
In this subsection we prove the main semantic results for our model – soundness and (strong) adequacy. In order to do so,we first have to prove some useful lemmas.As usual, the interpretation of values enjoys additional structural properties. emma 52.
For any value Γ ⊢ V : A , its interpretation J V K is a morphism of TD . Equivalently, it is in the image of J .Proof. Straightforward induction on the derivation of V .This means the interpretation of each closed value may be seen as a Dirac valuation. Next, we prove a substitution lemma. Lemma 53 (Substitution) . Let Γ ⊢ V : A be a value and Γ , x : A ⊢ M : B a term. Then: J M [ V /x ] K = J M K (cid:18) (id J Γ K . × J V K ) (cid:18) J h id J Γ K , id J Γ K i . Proof.
By induction on M using Lemma 52.Soundness and (strong) adequacy are formulated in terms of convex sums of the interpretations of terms. For a collectionof terms M i with Γ ⊢ M i : A , for each i ∈ I , each interpretation J M i K is a map in the Kegelspitze DCPO M ( J Γ K , J A K ) , so,we may form convex sums of these maps.Soundness is the statement that our interpretation is invariant under single-step reduction (in a probabilistic sense). Theorem 54 (Soundness) . For any term Γ ⊢ M : A , J M K = X M p −→ M ′ p J M ′ K , assuming M p −→ M ′ for some rule from Figure 4 and where the convex sum ranges over all such rules.Proof. Straightforward induction using Lemma 53.In the above theorem, the convex sum has at most two summands which are reached after a single reduction step. The next,considerably stronger statement, generalises this result to reductions involving an arbitrary number of steps.
Strong adequacy is the statement that the denotational interpretation is invariant with respect to reduction in a big-step sense (see [51], [8], [12]where such results are proven).
Theorem 55 (Strong Adequacy) . For any term · ⊢ M : A, J M K = X V ∈ Val( M ) P ( M −→ ∗ V ) J V K . Proof.
In Appendix D.
Remark . In the above theorem,
Val( M ) is defined in (1) and it may contain (countably) infinitely many elements; theconvex sum is defined in Definition 29.This theorem is also true to its name, because it immediately implies the usual notion of adequacy. Corollary 57 (Adequacy) . Let · ⊢ M : 1 be a term. Then J M K ( ∗ )( {∗} ) = Halt( M ) , (see (2) )where ∗ is the unique element of the singleton dcpo .Proof. Special case of Theorem 55 when A = 1 using the fact that if · ⊢ V : 1 is a value, then J V K ( ∗ )( {∗} ) = 1 ∈ R . The commutativity of our monad M implies that given any well-formed terms Γ ⊢ M : A and Γ ⊢ M : A and Γ , x : A , x : A ⊢ N : B , then J let x = M in let x = M in N K = J let x = M in let x = M in N K , (6)where let x = M in N may be defined using the usual syntactic sugar. This, together with adequacy (Corollary 57) and somestandard arguments (see [8]) implies that the programs in (6) are contextually equivalent. This improves on the results obtainedby Jones [12], because Equation 6 could not be established in her model without a proof that the monad V on DCPO iscommutative; as we commented earlier, this remains an open problem. We finally note that all results in this section also holdfor the monads W and P . UMMARY AND F UTURE WORK
We have constructed three commutative valuations monads on
DCPO that contain the simple valuations, and shown howto use any of them to give purely domain-theoretic models for
PFPC that are sound and adequate. Our construction usingtopological methods can be applied to any K -category K with K ⊆ D , offering the possibility of further such monads. We alsoidentified the Eilenberg-Moore algebras of each monad as consisting of Kegelspitzen. In the special case where we considercontinuous domains, we characterized the Eilenberg-Moore algebras over DOM of all three of our monads and also the V monad as precisely the continuous Kegelspitzen. We also proved the most general Fubini theorem for dcpo’s yet available.For future work, we are interested in applying our constructions to extensions of PFPC . For example, we believe ourconstructions can be extended to add sampling, scoring, conditioning and the other tools needed to model statistical probabilisticprogramming languages, such as those considered in [7], [8]. In particular, the authors of [8] comment that the lack of acommutative monad of valuations on
DCPO is what required them to develop the theory of ω -quasi-Borel spaces. We believeour approach could support a model of such a statistical programming language solely using domain-theoretic methods, wherewe can adapt the ideas from [52] to model random elements; we believe such a model would lead to a simplification of thedevelopment.In a different vein, we plan to apply our results to construct a model of a programming language that supports both classicalprobabilistic effects and also quantum resources. We have already identified a suitable type system, where the probabilisticeffects are induced by quantum measurements. We plan to interpret the quantum fragment in a category of von Neumannalgebras [53]. We also plan to show how the decomposition of classical probabilistic effects in terms of quantum ones can beinterpreted by moving between the Kleisli category of our monad M and the category of von Neumann algebras we identifiedusing the barycentre maps we described in this paper. R EFERENCES[1] M. O. Rabin, “Probabilistic algorithms,” in
Algorithms and complexity, recent results and new direction , J. F. Traub, Ed. Academic Press, 1976, pp.21–40.[2] J. Gill, “Computational complexity of probabilistic Turing machines,”
SIAM Journal on Computing , pp. 675–695, 1977.[3] J. Baeten, J. Bergstra, and S. Smolka, “Axiomatizing probabilistic processes: ACP with generative probabilities,”
Information and Computation , vol.121, pp. 234–255, 1995.[4] K. G. Larsen and A. Skou, “Bisimulation through probabilistic testing,” in
Proceedings of the 16th Annual ACM Symposium on Principles of ProgrammingLanguages . IEEE Press, 1989.[5] C. Morgan, A. McIver, and K. Seidel, “Probabilistic predicate transformers,”
ACM Transactions on Programming Languages and Systems , vol. 18, pp.325–353, 1996.[6] “Archive of workshops on probabilistic programming languages.” [Online]. Available: https://pps2017.luddy.indiana.edu/2017/01/[7] S. Staton, F. Wood, H. Yang, C. Heunen, and O. Kammar, “Semantics for probabilistic programming: higher-order functions, continuous distributions,and soft constraints,” in
Proceedings of 2016 31st Annual ACM/IEEE Symposium on Logic in Computer Science (LICS) . ACM Press, 2016.[8] M. Vákár, O. Kammar, and S. Staton, “A domain theory for statistical probabilistic programming,”
Proc. ACM Program. Lang. , vol. 3, no. POPL, pp.36:1–36:29, 2019. [Online]. Available: https://doi.org/10.1145/3290349[9] M. Pagani, P. Selinger, and B. Valiron, “Applying quantitative semantics to higher-order quantum computing,” in
The 41st Annual ACMSIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’14, San Diego, CA, USA, January 20-21, 2014 , S. Jagannathan andP. Sewell, Eds. ACM, 2014, pp. 647–658. [Online]. Available: https://doi.org/10.1145/2535838.2535879[10] K. Cho, “Semantics for a quantum programming language by operator algebras,”
New Generation Computing , vol. 34, pp. 25–68, 2016.[11] C. Jones and G. D. Plotkin, “A probabilistic powerdomain of evaluations,” in
Proceedings of the Fourth Annual Symposium on Logic inComputer Science (LICS ’89), Pacific Grove, California, USA, June 5-8, 1989 . IEEE Computer Society, 1989, pp. 186–195. [Online]. Available:https://doi.org/10.1109/LICS.1989.39173[12] C. Jones, “Probabilistic Non-determinism,” Ph.D. dissertation, University of Edinburgh, UK, 1990. [Online]. Available: http://hdl.handle.net/1842/413[13] A. Jung and R. Tix, “The troublesome probabilistic power domain,” in
Comprox III, Third Workshop on Computation and Approximation , vol. 13, 1998,pp. 70 – 91.[14] K. Keimel and J. D. Lawson, “D-completions and the d-topology,”
Ann. Pure Appl. Log. , vol. 159, no. 3, pp. 292–306, 2009. [Online]. Available:https://doi.org/10.1016/j.apal.2008.06.019[15] K. Keimel and G. D. Plotkin, “Mixed powerdomains for probability and nondeterminism,”
Logical Methods in Computer Science , vol. 13, Issue 1, Jan.2017. [Online]. Available: https://lmcs.episciences.org/2665[16] N. Saheb-Djagromi, “Cpos of measures for nondeterminism,”
Theoretical Computer Science , vol. 12, pp. 19–37, 1980.[17] E. Moggi, “Notions of Computation and Monads,”
Inf. Comput. , vol. 93, no. 1, pp. 55–92, 1991. [Online]. Available:https://doi.org/10.1016/0890-5401(91)90052-4[18] Anonymous, “Statistical Programming Languages meet Real PCF,” 2021, submitted to LICS 2021.[19] R. Tix, “Continuous d-cones: Convexity and powerdomain constructions,” Ph.D. dissertation, Technische Universität Darmstadt, 1999.[20] J. Goubault-Larrecq, “Continuous previsions,” in
Proceedings of the 16th Annual EACSL Conference on Computer Science Logic (CSL’07) , ser. LectureNotes in Computer Science, J. Duparc and Th. A. Henzinger, Eds., vol. 4646. Lausanne, Switzerland: Springer, Sep. 2007, pp. 542–557. [Online].Available: lsv.ens-cachan.fr/Publis/PAPERS/PDF/JGL-csl07.pdf[21] X. Jia and M. Mislove, “Completing Simple Valuations in K-categories,” 2020, preprint. [Online]. Available: https://arxiv.org/abs/2002.01865[22] T. Ehrhard and C. Tasson, “Probabilistic call by push value,”
Log. Methods Comput. Sci. , vol. 15, no. 1, 2019. [Online]. Available:https://doi.org/10.23638/LMCS-15(1:3)2019[23] T. Ehrhard, M. Pagani, and C. Tasson, “Full abstraction for probabilistic PCF,”
J. ACM , vol. 65, no. 4, pp. 23:1–23:44, 2018. [Online]. Available:https://doi.org/10.1145/3164540[24] C. Heunen, O. Kammar, S. Staton, and H. Yang, “A convenient category for higher-order probability theory,” in . IEEE Computer Society, 2017, pp. 1–12. [Online]. Available:https://doi.org/10.1109/LICS.2017.800513725] A. Edalat, “Domain theory and integration,” in
Annual IEEE Symposium on Logic in Computer Science, LICS 1994
Mathematical Structures for Computer Science , vol. 7, pp. 401–417, 1997.[27] M. Alvarez-Manilla, A. Edalat, and N. Saheb-Djarhomi, “An extension result for continuous valuations,”
Electronic Notes in Theoretical ComputerScience , vol. 13, 1998.[28] M. Rennela, “Convexity and order in probabilistic call-by-name FPC,”
LMCS , vol. 16, 2020.[29] M. Abadi and M. P. Fiore, “Syntactic considerations on recursive types,” in
Proceedings 11th Annual IEEE Symposium on Logic in Computer Science ,July 1996, pp. 242–252.[30] M. P. Fiore, “Axiomatic domain theory in categories of partial maps,” Ph.D. dissertation, University of Edinburgh, UK, 1994.[31] M. Fiore and G. Plotkin, “An axiomatization of computationally adequate domain theoretic models of FPC,” in
LICS . IEEE Computer Society, 1994,pp. 92–102.[32] R. Harper,
Practical Foundations for Programming Languages (2nd. Ed.) . IEEE, 2019, pp. 1–13. [Online]. Available: https://doi.org/10.1109/LICS.2019.8785699[34] S. Abramsky and A. Jung, “Domain Theory,” in
Handbook of Logic in Computer Science (Vol. 3) . Oxford, UK: Oxford University Press, 1994, pp.1–168. [Online]. Available: http://dl.acm.org/citation.cfm?id=218742.218744[35] G. Gierz, K. H. Hofmann, K. Keimel, J. D. Lawson, M. W. Mislove, and D. S. Scott,
Continuous Lattices and Domains , ser. Encyclopedia of Mathematicsand Its Applications 93. Cambridge University Press, 2003.[36] W. K. Ho, J. Goubault-Larrecq, A. Jung, and X. Xi, “The Ho-Zhao problem,”
Log. Methods Comput. Sci. , vol. 14, no. 1, 2018. [Online]. Available:https://doi.org/10.23638/LMCS-14(1:7)2018[37] E. G. Manes,
Algebraic Theories , ser. Graduate Texts in Mathematics. Springer-Verlag, 1976, vol. 26. [Online]. Available:https://doi.org/10.1007/978-1-4612-9860-1[38] D. Zhao and T. Fan, “Dcpo-completion of posets,”
Theor. Comput. Sci. , vol. 411, no. 22-24, pp. 2167–2173, 2010. [Online]. Available:https://doi.org/10.1016/j.tcs.2010.02.020[39] R. Heckmann, “Spaces of valuations,” in
Papers on General Topology and Applications: Eleventh Summer Conference at the University of SouthernMaine , ser. Annals of the New York Academy of Sciences, S. Andima, R. C. Flagg, G. Itzkowitz, P. Misra, Y. Kong, and R. Kopperman, Eds., vol. 806,1996, pp. 174–200.[40] J. Goubault-Larrecq, “A short proof of the Schröder-Simpson Theorem,”
Math. Struct. Comput. Sci. , vol. 25, no. 1, pp. 1–5, 2015. [Online]. Available:https://doi.org/10.1017/S0960129513000467[41] G. Wu, X. Xi, X. Xu, and D. Zhao, “Existence of well-filterifications of T topological spaces,” Topology and its Applications , vol. 270, no. 1, 2020.[42] B. Jacobs,
Introduction to Coalgebra: Towards Mathematics of States and Observation , ser. Cambridge Tracts in Theoretical Computer Science.Cambridge University Press, 2016, vol. 59. [Online]. Available: https://doi.org/10.1017/CBO9781316823187[43] J. Power and E. Robinson, “Premonoidal Categories and Notions of Computation,”
Math. Struct. Comput. Sci. , vol. 7, no. 5, pp. 453–468, 1997.[Online]. Available: https://doi.org/10.1017/S0960129597002375[44] S. Mac Lane,
Categories for the Working Mathematician (2nd ed.) . Springer, 1998.[45] F. Borceux,
Handbook of Categorical Algebra 2: Categories and Structures . Cambridge University Press, 1994.[46] P. Benton, “A mixed linear and non-linear logic: Proofs, terms and models,” in
Computer Science Logic: 8th Workshop, CSL ’94, Selected Papaers ,1995. [Online]. Available: http://dx.doi.org/10.1007/BFb0022251[47] P. N. Benton and P. Wadler, “Linear logic, monads and the lambda calculus,” in
LICS 1996 , 1996.[48] M. Smyth and G. Plotkin, “The Category-theoretic Solution of Recursive Domain Equations,”
Siam J. Comput. , 1982.[49] B. Lindenhovius, M. W. Mislove, and V. Zamdzhiev, “LNL-FPC: The Linear/Non-linear Fixpoint Calculus,” 2020, available athttp://arxiv.org/abs/1906.09503. [Online]. Available: http://arxiv.org/abs/1906.09503[50] B. Lindenhovius, M. Mislove, and V. Zamdzhiev, “Mixed Linear and Non-linear Recursive Types,”
Proc. ACM Program. Lang. , vol. 3, no. ICFP, pp.111:1–111:29, Aug. 2019. [Online]. Available: http://doi.acm.org/10.1145/3341715[51] T. Leventis and M. Pagani, “Strong Adequacy and Untyped Full-Abstraction for Probabilistic Coherence Spaces,” in
Foundations of Software Scienceand Computation Structures - 22nd International Conference, FOSSACS 2019, Held as Part of the European Joint Conferences on Theory andPractice of Software, ETAPS 2019, Prague, Czech Republic, April 6-11, 2019, Proceedings , ser. Lecture Notes in Computer Science, M. Bojanczykand A. Simpson, Eds., vol. 11425. Springer, 2019, pp. 365–381. [Online]. Available: https://doi.org/10.1007/978-3-030-17127-8_21[52] M. Mislove, “Domains and stochastic processes,”
Theoretical Computer Science
J. Math. Phys. , vol. 61, p. 102202, 2020. [Online]. Available: https://doi.org/10.1063/1.5054128
PPENDIX AM ONADS , COMMUTATIVITY AND M - ALGEBRAS
Let D be a dcpo. Recall that the d-topology on D consists of all sub-dcpo’s of D as closed subsets. The d-topology on D is finer than the Scott topology. In fact D is even Hausdorff in the d-topology: for x y in D , D \ ↓ y and ↓ y are disjointopen sets in the d-topology, containing x and y respectively. Functions that are continuous between dcpo’s equipped with thed-topology are called d-continuous functions. Scott-continuous functions between dcpo’s are d-continuous [38, Lemma 5].Recall that M D is the smallest sub-dcpo of V D that contains S D , hence M D is actually the topological closure of S D in V D equipped with the d-topology. Hence we also say that M D is the d-closure of S D inside V D .Let f : D → [0 , be a Scott-continuous function and ν ∈ V D . The integral R x ∈ D f ( x ) dν , defined as the Riemann integral R ν ( f − (( t, dt , satisfies the following properties, which can be found in [12]. Proposition 58.
Let D be a dcpo, f : D → [0 , be a Scott-continuous function. Then we have the following: The map ( ν i P ni =1 r i ν i ) : V D → V D is Scott-continuous hence d-continuous, for fixed ν j , j = i and r i , i = 1 , . . . , n with P ni =1 r i ≤ . For P ni =1 r i ν i ∈ V D , it is true that R f d P ni =1 r i ν i = P ni =1 r i R f dν i . For ν ∈ V D and f, g ∈ [ D → [0 , , R rf + sgdν = r R f dν + s R gdν for r + s ≤ . Proof of Lemma 7 .
We prove the case n = 2 and the general case can be proved similarly. We realize that for a fixed simplevaluation s ∈ S D , the map ( ν r ν + r s ) : V D → V D maps S D into S D . From the previous proposition, Item 1, this mapis d-continuous, it then maps the dcpo-closure of S D , which is M D , into M D , the dcpo-closure of S D . That is, for eachsimple valuation s and each ν ∈ M D , r ν + r s ∈ M D . Now we fix ν ∈ M D . Then the map ξ r ν + r ξ : V D → V D maps S D into M D , hence it also maps M D into M D since it is d-continuous. This means for ξ, ν ∈ M D , r , r ∈ [0 , with r + r ≤ , r ν + r ξ ∈ M D . Proof of Theorem 21.
To prove this theorem, we first recall two results due to Heckmann [39, Theorem 2.4, Theorem 5.5].Specifying these results to dcpo D , it implies that if ν is a point-continuous valuation in P D , and ν ∈ O for O an open setin P w D , then there exists a simple valuation P ni =1 r i δ x i ∈ S D such that P ni =1 r i δ x i ≤ ν and P ni =1 r i δ x i ∈ O .Now we fix ξ ∈ P E and U ∈ σ ( D × E ) , and consider the functions F : V w D → [0 , ∞ ] : ν Z x ∈ D Z y ∈ E χ U ( x, y ) dξdν and G : V w D → [0 , ∞ ] : ν Z y ∈ E Z x ∈ D χ U ( x, y ) dνdξ, where [0 , ∞ ] is equipped with the Scott topology. We claim that F and G are continuous.The fact that F is continuous is straightforward from Remark 13. To see that G is continuous, we assume that R y ∈ E R x ∈ D χ U dνdξ > r and aim to find an open set U of V w D such that ν ∈ U and for any ν ′ ∈ U , R y ∈ E R x ∈ D χ U dν ′ dξ > r .To this end, we note that g : E → [0 ,
1] : y R x ∈ D χ U ( x, y ) dν is Scott-continuous. Hence [ g > r ] ∩ P E is an open subset of P w E that contains ξ . Applying the aforementioned result we find a simple valuation P ni =1 r i δ y i ∈ S E such that P ni =1 r i δ y i ≤ ξ and P ni =1 r i δ y i ∈ [ g > r ] . This implies that Z y ∈ E Z x ∈ D χ U ( x, y ) dνd n X i =1 r i δ y i > r. By applying Equation 3, this in turn implies that n X i =1 Z x ∈ D r i χ U ( x, y i ) dν > r. Obviously, we could find s i ≥ , i = 1 , . . . , n such that R x ∈ D r i χ U ( x, y i ) dν > s i and P ni =1 s i > r . Now we let U = n \ i =1 [ r i χ U ( x, y i ) > s i ] . By Remark 13 the set U is open in V w D and obviously ν ∈ U . Moreover, for any ν ′ ∈ U , we have Z y ∈ E Z x ∈ D χ U ( x, y ) dν ′ dξ ≥ Z y ∈ E Z x ∈ D χ U ( x, y ) dν ′ d n X i =1 r i δ y i = n X i =1 Z x ∈ D r i χ U ( x, y i ) dν ′ ≥ n X i =1 s i > r. ence G is continuous indeed.The functions F and G are also linear from Proposition 58, Item 2. Hence both F and G are continuous linear map from V w D to [0 , ∞ ] , we now apply a varied version of the Schröder-Simpson Theorem, which can be found in [40, Corollary 2.5],to see that F and G are uniquely determined by their actions on Dirac measures δ a , a ∈ D . However, we note that F ( δ a ) = R y ∈ E χ U ( a, y ) dξ = G ( δ a ) , again by Equation 3. Hence F = G , and we finish the proof by letting ξ range in P w E . Proof of Theorem 22.
We only need to prove that the strength of V K , ≤ exists, and is of the same form as τ V , the strengthof V , and then conclude with Theorem 21.We know that for each K -category K ⊆ D , V K , ≤ is a monad on DCPO . Hence, for any dcpo’s D and E , and anyScott-continuous map f : D → V K , ≤ E , the function f † : V K , ≤ D → V K , ≤ E : ν λU ∈ σE. Z x ∈ D f ( x )( U ) dν is a well-defined Scott-continuous map.Now we apply this fact to the map g : E → V K , ≤ ( D × E ) : y δ ( a,y ) , where a is any fixed element in D . The map g isobviously Scott-continuous. Hence for any ν ∈ V K , ≤ E , g † ( ν ) = λU ∈ σ ( D × E ) . Z y ∈ E δ ( a,y ) ( U ) dν = λU ∈ σ ( D × E ) . Z y ∈ E χ U ( a, y ) dν is in V K , ≤ ( D × E ) . This implies the map τ D,E : D × V K , ≤ E → V K , ≤ ( D × E ) : ( a, ν ) λU ∈ σ ( D × E ) . Z y ∈ E χ U ( a, y ) dν is well-defined, and it is obviously Scott-continuous. Note that apart from the domain and codomain, the map τ D,E is sameto the strength τ V D,E of V at ( D, E ) . Then the same arguments as in Jones’ thesis would show that τ D,E is the strength of V K , ≤ at ( D, E ) . Hence V K , ≤ is a strong monad. Proof of Proposition 33.
We first prove that K is a pointed barycentric algebra. It is easy to see that β ( K ) is the leastelement in K , since for any x ∈ K , β ( K ) ≤ β ( δ x ) = x . It is also easy to see that a + b = a , a + r b = b + − r a and a + r a = a . We now proceed to prove that ( a + p b ) + r c = a + pr ( b + r − pr − pr c ) for any r, p < and a, b, c ∈ K . To this end,we perform the following: ( a + p b ) + r c = β ( δ a + p b + r δ c ) definition of + r = β ( δ β ( δ a + p δ b ) + r δ β ( δ c ) ) definition of + p and β ( δ c ) = c = β ( M ( β )( δ δ a + p δ b + r δ δ c )) M ( β ) is linear and M ( β )( δ ν ) = δ β ( ν ) = β ( µ M K ( δ δ a + p δ b + r δ δ c )) ( K, β ) is an M -algebra = β (( δ a + p δ b ) + r δ c ) µ M K is the multiplication of M at K = β ( δ a + pr ( δ b + r − rp − pr δ c )) M K is a Kegelspitze = β ( µ M K ( δ δ a + pr δ ( δ b + r − rp − pr δ c ) )) µ M K is the multiplication of M at K = β ( M ( β )( δ δ a + pr δ ( δ b + r − rp − pr δ c ) )) ( K, β ) is an M -algebra = β ( δ β ( δ a ) + pr δ β ( δ b + r − rp − pr δ c ) ) M ( β ) is linear and M ( β )( δ ν ) = δ β ( ν ) = β ( δ a + pr δ ( b + r − rp − pr c ) ) definition of b + r − rp − pr c and β ( δ a ) = a = a + pr ( b + r − pr − pr c ) . definition of + pr The map ( a, b ) a + r b = β ( δ a + r δ b ) : K × K → K is Scott-continuous since β and δ are Scott-continuous and M K is aKegelspitze. The map ( r, a ) ra = a + r β ( K ) = β ( δ a + r δ β ( K ) ) : [0 , × K → K is Scott-continuous in a for the exactlysame reasons; to see that it also is Scott-continuous in r , we only need to show that r δ a + r δ β ( K ) : [0 , → M K isScott-continuous for any fixed a ∈ K . This is true if β ( K ) ≤ a . However, we already see that β ( K ) is the least element in K . Hence we have proved that K is a Kegelspitze. The map β is clearly linear. Proof of Proposition 34. he “if” direction : Assume that f : K → K is linear. We need to prove that f ◦ β = β ◦ M ( f ) . Since both sidesare Scott-continuous hence d-continuous and K is Hausdorff in the d-topology (if K has more than one elements). We onlyneed to prove they are equal on simple valuations on K . To this end, we pick P ni =1 r i δ x i ∈ M K , and see f ( β ( n X i =1 r i δ x i )) = f ( n X i =1 r i x i ) β is linear and β ( δ x i ) = x i = n X i =1 r i f ( x i ) f is linear = β ( n X i =1 r i δ f ( x i ) ) β is linear and β ( δ f ( x i ) ) = f ( x i )= β ( M ( f )( n X i =1 r i δ x i )) . M ( f ) is linear and M ( f )( δ x i ) = δ f ( x i ) The “only if” direction : Assume that f : K → K is an algebra morphism from ( K , β ) to ( K , β ) . Then we knowthat f ◦ β = β ◦ M ( f ) . We prove that f is linear. First, for a, b ∈ K and r ∈ [0 , , we have f ( a + r b ) = f ( β ( δ a + r δ b )) definition of a + r b = β ( M ( f )( δ a + r δ b )) f is an algebra morphism = β ( δ f ( a ) + r δ f ( b ) ) M ( f ) is linear and M ( f )( δ x ) = δ f ( x ) = f ( a ) + r f ( b ) . definition of f ( a ) + r f ( b ) Second, to prove that f maps β ( K ) to β ( K ) , we see that f ( β ( K )) = β ( M ( f )( K )) = β ( K ) because M ( f ) islinear. PPENDIX BS OLVING R ECURSIVE D OMAIN E QUATIONS IN
DCPO M We use ( M , η, µ, τ ) to indicate our commutative monad and we write ( L , η L , µ L , τ L ) to indicate the lift monad on DCPO ,which is also commutative.Recall that the lift monad L : DCPO → DCPO freely adds a new least element, often denoted ⊥ , to a dcpo X . Theresulting dcpo is L X def = X ⊥ . The monad structure of L is defined by the following assignments: η L X : X → X ⊥ x x µ L X : ( X ⊥ ) ⊥ → X ⊥ x ⊥ , if x = ⊥ ⊥ , if x = ⊥ x , if ⊥ = x = ⊥ τ L XY : X ⊥ × Y → ( X × Y ) ⊥ ( x, y ) ( ⊥ , if x = ⊥ ( x, y ) , if x = ⊥ We write
DCPO L for the Kleisli category of L and we write its morphisms as f : X ⇀ Y, which is by definitiona morphism f : X → Y ⊥ in DCPO . We write X ⊗ Y and X ⊕ Y for the symmetric monoidal product and coproduct,respectively, which are (canonically) induced by the commutative monad L . Proposition 59.
The assignment φ : L ⇒ M defined by φ X : X ⊥ → M Xx ( X , if x = ⊥ δ x , if x = ⊥ is a strong map of monads (see [42, Definition 5.2.9] for more details).Proof. To see that φ is a natural transformation, we need to show, for any Scott-continuous map f : X → Y , φ Y ◦ L f = M f ◦ φ X : X ⊥ → M Y . However, it is easy to see that both sides send ⊥ to Y and x that is not ⊥ to δ f ( x ) .Now, we first verify that φ is a map of monads. That is, for each dcpo X , we need to prove that φ X ◦ η L X = η X and φ X ◦ µ L X = µ X ◦ M ( φ X ) ◦ φ X ⊥ : ( X ⊥ ) ⊥ → M ( X ) .The first equation is trivial, hence we proceed to prove the second. For this, we see φ X ◦ µ L X ( x ) = ( φ X ( ⊥ ) = X , if x = ⊥ or x = ⊥ φ X ( x ) = δ x , if ⊥ = x = ⊥ and µ X ◦ M ( φ X ) ◦ φ X ⊥ ( x ) = µ X ◦ M ( φ X )( X ⊥ ) = µ X ( M X ) = X , if x = ⊥ µ X ◦ M ( φ X )( δ ⊥ ) = µ X ( δ φ X ( ⊥ ) ) = µ X ( δ X ) = X , if x = ⊥ µ X ◦ M ( φ X )( δ x ) = µ X ( δ φ X ( x ) ) = µ X ( δ δ x ) = δ x , if ⊥ = x = ⊥ . Hence φ : L ⇒ M is a map of monads.To prove that φ is a strong map of monads, we need to show that for any dcpo’s X and Y , τ XY ◦ ( φ X × id Y ) = φ XY ◦ τ L XY : X ⊥ × Y → M ( X × Y ) . The strength τ of M at ( X, Y ) is defined as follows: τ XY : M X × Y → M ( X × Y ) : ( ν, y ) λU. Z x ∈ X χ U ( x, y ) dν, where χ U is the characteristic function of U ∈ σ ( X × Y ) , i.e., χ U ( x, y ) = 1 if ( x, y ) ∈ U and χ U ( x, y ) = 0 , otherwise. Nowwe perform the following computation τ XY ◦ ( φ X × id Y )( x, y ) = ( τ XY ( X , y ) = λU. R x ∈ X χ U ( x, y ) d X = λU. X × Y , if x = ⊥ τ XY ( δ x , y ) = λU. R x ∈ X χ U ( x, y ) dδ x = λU.χ U ( x, y ) = δ ( x,y ) , if x = ⊥ and φ XY ◦ τ L XY ( x, y ) = ( φ XY ( ⊥ ) = X × Y , if x = ⊥ φ XY (( x, y )) = δ ( x,y ) , if x = ⊥ which concludes the proof.Recall that any map of monads induces a functor between the corresponding Kleisli categories of the two monads (see [42,Exercise 5.2.1]). This allows us to show the next corollary. orollary 60. The functor F : DCPO L → DCPO M , induced by φ : L ⇒ M , and defined by: F X def = X F ( f : X ⇀ Y ) def = φ Y ◦ f strictly preserves the monoidal and coproduct structures in the sense that the following equalities: F ( X ⊗ Y ) = F X . × F Y F ( X ⊕ Y ) = F X . + F Y F ( f ⊗ g ) = F f . × F g F ( f ⊕ g ) = F f . + F g hold.Proof. This follows by canonical categorical arguments and is just a straightforward verification.Before we may prove our next proposition, let us recall an important result from [48].
Proposition 61.
Let A , B and C be DCPO -enriched categories. Assume further that A and B have all ω -colimits (or all ω op -limits). If T : A op × B → C is a DCPO -enriched functor, then the assignment T E : A e × B e → C e T E ( A, B ) def = T ( A, B ) T E ( e , e ) def = T ( e p , e ) defines a covariant ω -cocontinuous functor.Proof. This follows by combining several results from [48], namely Theorem 2, the corollary after it and Theorem 3.Therefore, by trivialising the category A , we may obtain results for purely covariant functors. When neither category istrivialised, this allows us to interpret mixed-variance functors (such as function space) as covariant functors on subcategoriesof embeddings. Proposition 62.
The category PD e has an initial object and all ω -colimits and the following assignments: . × e : PD e × PD e → PD e . + e : PD e × PD e → PD e X . × e Y def = X . × Y X . + e Y def = X . + Ye . × e e def = e . × e e . + e e def = e . + e [ . → ] J e : PD e × PD e → PD e [ X . → Y ] J e def = J [ X . → Y ][ e . → e ] J e def = J [ e p . → e ] define covariant ω -cocontinuous functors on PD e .Proof. The empty dcpo ∅ is a zero object in PD such that each map e : ∅ . → X is an embedding and each map p : X . → ∅ is aprojection. Therefore, ∅ is initial in PD e . The existence of all ω -colimits in PD e follows from the existence of all ω -colimitsof PD together with results from [48].Next, we show that . × : DCPO M × DCPO M → DCPO M restricts to a functor . × PD : PD × PD → PD . On objects, thisis obvious. For morphisms, observe that the morphisms of PD are exactly those which are in the image of F . Therefore . × PD restricts as indicated because F f . × F g = F ( f ⊗ g ) by Corollary 60. Then, by Proposition 61, it follows that ( . × PD ) E : PD e × PD e → PD e is a covariant ω -cocontinuous functor. However, by definition, . × e = ( . × PD ) E which shows the result for . × e .Exactly the same argument (swapping . × for . + and ⊗ for ⊕ ) shows the result for . + e .For function spaces, consider the functor J ◦ [ . → ] : DCPO op M × DCPO M → DCPO M . This composition (co)restricts toa functor ( J ◦ [ . → ]) PD : PD op × PD → PD , because J ( f . → g ) = η ◦ ( f . → g ) = φ ◦ η L ◦ ( f . → g ) = F ( η L ◦ ( f . → g )) . ByProposition 61, it follows (( J ◦ [ . → ]) PD ) E : PD e × PD e → PD e is a covariant ω -cocontinuous functor. Finally, by definition, [ . → ] J e = (( J ◦ [ . → ]) PD ) E which concludes the proof.We conclude the appendix with a proof that the subcategories TD and PD contain the same isomorphisms. Proposition 63.
Every isomorphism of PD is also an isomorphism of TD .roof. Observe that, by definition, the morphisms of TD are those in the image of J : DCPO → DCPO M and themorphisms of PD are those in the image of F : DCPO L → DCPO M . Then, it is easy to see that the following diagram:
TD PDDCPO L DCPO J L ∼ = ∼ = commutes, where: • the top arrow is the subcategory inclusion TD ֒ → PD ; • the left vertical isomorphism is the corestriction of J to TD ; • the right vertical isomorphism is the corestriction of F to PD ; • the functor J L is the Kleisli inclusion of DCPO into
DCPO L , defined by J L ( X ) def = X and J L ( f ) def = η L ◦ f. It is well-known (and easy to prove) that if f : X ⇀ Y in DCPO L is an isomorphism, then there exists f ′ : X → Y in DCPO which is also an isomorphism and f = J L ( f ′ ) . The proof is finished by a simple diagram chase using this fact.
PPENDIX CP RODUCTS , COPRODUCTS AND K LEISLI COMPOSITION PRESERVE BARYCENTRIC SUMS OF FUNCTIONS
The monoidal product _ . × _ : DCPO M × DCPO M → DCPO M is defined as: for dcpo’s A and B , A . × B def = A × B , and forScott-continuous maps f : A → M C and g : B → M D , f . × g def = λ ( a, b ) .f ( a ) ⊗ g ( b ) , where f ( a ) ⊗ g ( b ) is defined in Remark 10.For f, h : A → M C and r ∈ [0 , , f + r h is defined pointwise, that is, ( f + r h )( a ) = f ( a ) + r h ( a ) = rf ( a ) + (1 − r ) h ( a ) . It follows from Lemma 7 that f + r h is well-defined and obviously f + r h is Scott-continuous, hence f + r h ∈ [ A → M C ] . Proposition 64.
For f, h : A → M C , g : B → M D and r ∈ [0 , , we have ( f + r h ) . × g = f . × g + r h . × g : A . × B → M ( C . × D ) ; g . × ( f + r h ) = g . × f + r g . × h : B . × A → M ( D . × C ) .Proof. We only prove Item 1, the second item can be proved similarly.For each ( a, b ) ∈ A . × B , we have the following: (( f + r h ) . × g )( a, b )= ( f + r h )( a ) ⊗ g ( b ) definition of _ . × _ = ( f ( a ) + r h ( a )) ⊗ g ( b ) definition of f + r h = λU ∈ σ ( C . × D ) . Z y ∈ D Z x ∈ C χ U ( x, y ) d ( f ( a ) + r h ( a )) dg ( b ) definition of the operation ⊗ = λU. Z y ∈ D ( Z x ∈ C χ U ( x, y ) df ( a ) + r Z x ∈ C χ U ( x, y ) dh ( a )) dg ( b ) by Proposition 58, Item 2 = λU. Z y ∈ D Z x ∈ C χ U ( x, y ) df ( a ) dg ( b ) + r Z y ∈ D Z x ∈ C χ U ( x, y ) dh ( a ) dg ( b ) by Proposition 58, Item 3 = λU. Z y ∈ D Z x ∈ C χ U ( x, y ) df ( a ) dg ( b ) + r λU. Z y ∈ D Z x ∈ C χ U ( x, y ) dh ( a ) dg ( b ) by definition of + r of valuations = ( f . × g )( a, b ) + r ( h . × g )( a, b ) definition of _ . × _ = ( f . × g + r h . × g )( a, b ) definition of + r of functions.Hence the proof is completed.The functor _ . + _ : DCPO M × DCPO M → DCPO M is defined as: for dcpo’s A and B , A . + B def = A + B , and forScott-continuous maps f : A → M C and g : B → M D , f . + g = [ M ( i C ) ◦ f, M ( i D ) ◦ g ] , where i C : C → C + D and i D : D → C + D are the obvious injections. Proposition 65.
For f, h : A → M C, g : B → M D and r ∈ [0 , , we have ( f + r h ) . + g = ( f . + g ) + r ( h . + g ) ; g . + ( f + r h ) = ( g . + f ) + r ( g . + h ) .Proof. Again, we only prove the first claim as the second can be proved similarly. Let a ∈ A , we perform the followingcomputation: (( f + r h ) . + g )( i A ( a )) = [ M ( i C ) ◦ ( f + r h ) , M ( i D ) ◦ g ]( i A ( a )) definition of _ . + _ = M ( i C )(( f + r h )( a )) obvious = M ( i C )( f ( a ) + r h ( a )) definition of f + r h = λU. ( f ( a ) + r h ( a ))( i − C ( U )) definition of M ( i C )= λU.f ( a )( i − C ( U )) + r h ( a )( i − C ( U )) definition of f ( a ) + r h ( a )= λU.f ( a )( i − C ( U )) + r λU.h ( a )( i − C ( U )) definition of + r of valuations = M ( i C )( f ( a )) + r M ( i C )( h ( a )) , definition of M ( i C )= ( f . + g )( i A ( a )) + r ( h . + g )( i A ( a )) definition of _ . + _ = (( f . + g ) + r ( h . + g ))( i A ( a )) . definition of ( f . + g ) + r ( h . + g ) Moreover, it is easy to see that for b ∈ B , (( f + r h ) . + g )( i B ( b )) = M ( i D )( g ( b )) = M ( i D )( g ( b )) + r M ( i D )( g ( b )) =(( f . + g ) + r ( h . + g ))( i B ( b )) . Hence we finish the proof.Recall that in DCPO M the Kleisli composition (cid:18) : [ A . → B ] × [ B . → C ] → [ A . → C ] is given by ( f, g ) g (cid:18) f = g ‡ ◦ f. roposition 66. For f, h : A → M B, g, k : B → M C and r ∈ [0 , , we have g (cid:18) ( f + r h ) = g (cid:18) f + r g (cid:18) h ; ( g + r k ) (cid:18) f = g (cid:18) f + r k (cid:18) f .Proof.
1) Let a ∈ A . We have g (cid:18) ( f + r h )( a ) = ( g ‡ ◦ ( f + r h ))( a ) definition of (cid:18) = g ‡ ( f ( a ) + r h ( a )) definition of f + r h = λU. Z x ∈ B g ( x )( U ) d ( f ( a ) + r h ( a )) definition of g ‡ = λU. Z x ∈ B g ( x )( U ) df ( a ) + r λU. Z x ∈ B g ( x )( U ) dh ( a ) by Proposition 58, Item 2 = g ‡ ( f ( a )) + r g ‡ ( h ( a )) definition of g ‡ = ( g (cid:18) f + r g (cid:18) h )( a ) .
2) Let a ∈ A . We have (( g + r k ) (cid:18) f )( a ) = ( g + r k ) ‡ ( f ( a )) definition of (cid:18) = λU. Z x ∈ B ( g + r k )( x )( U ) df ( a ) definition of _ ‡ = λU. Z x ∈ B g ( x )( U ) df ( a ) + r λU. Z x ∈ B k ( x )( U ) df ( a ) by Proposition 58, Item 3 = g ‡ ( f ( a )) + r k ‡ ( f ( a )) definition of _ ‡ = ( g (cid:18) f + r k (cid:18) f )( a ) . PPENDIX DP ROOF OF S TRONG A DEQUACY
The purpose of this appendix is to provide a proof Theorem 55. We begin by stating a corollary for the soundness theorem.
Corollary 67.
For any closed term · ⊢ M : A , we have: J M K ≥ X V ∈ Val( M ) P ( M −→ ∗ V ) J V K . Proof.
First, let us decompose the convex sum on the right-hand side. X V ∈ Val( M ) P ( M −→ ∗ V ) J V K = sup F ⊆ Val( M ) F finite X V ∈ F P ( M −→ ∗ V ) J V K (Definition) = sup F ⊆ Val( M ) F finite X V ∈ F (cid:18) sup i ∈ N P ( M −→ ≤ i V ) (cid:19) J V K (Definition) = sup F ⊆ Val( M ) F finite sup i ∈ N X V ∈ F P ( M −→ ≤ i V ) J V K Scott-continuity of X i r i a i in each r i ! . Therefore, it suffices to show that J M K ≥ X V ∈ F P ( M −→ ≤ i V ) J V K (7)for any choice of finite F ⊆ Val( M ) and i ∈ N . This can now be shown by induction on i . If M ∈ F (which means M is avalue), then (7) is a strict equality. Assume M F . If i = 0 , then the right-hand side of (7) is 0 and so the inequality holds.For the step case, if M is a value, then RHS is 0 and the inequality holds. Otherwise: X V ∈ F P ( M −→ ≤ i +1 V ) J V K = X V ∈ F X M p −→ M ′ p · P ( M ′ −→ ≤ i V ) J V K = X M p −→ M ′ p · X V ∈ F P ( M ′ −→ ≤ i V ) J V K ≤ X M p −→ M ′ p · J M ′ K ( IH for M ′ )= J M K ( Soundness ) where we also implicitly used the fact that Val( M ′ ) ⊆ Val( M ) . The remainder of the appendix is dedicated to showing the converse inequality, which is considerably more difficult to prove.
A. Overview of the Proof Strategy
The proof of strong adequacy requires considerable effort. Our proof strategy consists in formulating logical relations that weuse to prove our adequacy result. These logical relations are described in Theorem 107 and the design of our logical relationsfollows that of Claire Jones in her thesis [12]. Once this theorem is proved, the proof of adequacy is fairly straightforward.We use the logical relations to establish some useful closure properties in Subsection D-F and this allows us to easily proveLemma 117, which is often called the Fundamental Lemma. This lemma easily implies Strong Adequacy as we show.Most of the effort in proving our Strong Adequacy result lies in the proof of Theorem 107. It is not possible to use theproperties (A1) – (A4) as a definition of the relations, because then condition (A4) would be defined via non-well-foundedinduction. The proof of the existence of this family of relations is not obvious. We use techniques from [49], [50] (which arein turn based on ideas from [30]) to show the existence of these relations. The main idea of the proof of existence is to define,for every type A , a category R ( A ) of logical relations with a suitable notion of morphism. We then show that every suchcategory has sufficient structure to construct parameterised initial algebras (Proposition 87). We may then define functors onthese categories (Definition 94) which construct logical relations in the same manner as they are needed in Theorem 107. Thesefunctors are ω -cocontinuous (Proposition 96) which means that we may form (parameterised) initial algebras using them. Thisallows us to define an augmented interpretation of types on the categories R ( A ) which satisfies some important coherenceconditions with respect to the standard interpretation of types (Corollary 105). These coherence conditions show that eachaugmented interpretation k A k of a type A contains the standard interpretation J A K , together with the logical relation that weneed, as shown in Theorem 107. . Logical Relations Assumption 68.
Throughout this appendix, we assume that all types are closed, unless otherwise noted.
Definition 69.
For each type A , we write: • Val( A ) def = { V | V is a value and · ⊢ V : A } . • Prog( A ) def = { M | M is a term and · ⊢ M : A } . Next, we define sets of relations that are parameterised by dcpo’s X from our semantic category, types A from our languageand partial deterministic embeddings e X : X . → J A K which show how X approximates J A K . We shall write relation membershipin infix notation, that is, for a binary relation ⊳ , we write v ⊳ V to indicate ( v, V ) ∈ ⊳ . Definition 70.
For any dcpo X , type A and morphism e : X . → J A K in PD e , let: ValRel(
X, A, e ) = { ⊳ eX,A ⊆ TD (1 , X ) × Val( A ) | ∀ V ∈ Val( A ) . ( − ) ⊳ eX,A V is a Scott closed subset of TD (1 , X ) and ∀ V ∈ Val( A ) . v ⊳ eX,A V ⇒ e (cid:18) v ≤ J V K } . Remark . In the above definition, relations ⊳ eX,A ∈ ValRel(
X, A, e ) can be seen as ternary relations ⊳ eX,A ⊆ TD (1 , X ) × Val( A ) × { e } . However, since there is no choice for the third component, we prefer to see them as binary relations thatare parameterised by the embeddings e . Indeed, this leads to a much nicer notation. We shall also sometimes indicate theparameters X, A and e of the relation in order to avoid confusion as to which set ValRel(
X, A, e ) it belongs to.The relations we need for the adequacy proof inhabit the sets ValRel( J A K , A, id J A K ) . In the remainder of the appendix, wewill show how to choose exactly one relation (the one we need) from each of those sets.Before we may define the relation constructors we need, we have to introduce some auxiliary definitions. Definition 72.
Let M : A and N : A be closed terms of the same type. We define Paths(M , N) def = n π | π = (cid:16) M = M p −→ M p −→ M p −→ · · · p n −→ M n = N (cid:17) is a reduction path o . In other words,
Paths(M , N) is the set of all reduction paths from M to N . The probability weight of a path π ∈ Paths(
M, N ) is P ( π ) def = Q ni =0 p i , i.e., it is simply the product of all the probabilities of single-step reductions within the path. The set ofterminal reduction paths of M is TPaths(M) def = [ V ∈ Val( A ) Paths(
M, V ) . Thus the endpoint of any path π ∈ TPaths( M ) is a value. If π ∈ Paths(
M, W ) , where W is a value, then we shall write V π def = W. That is, for a path π ∈ TPaths( M ) , the notation V π indicates the endpoint of the path π which is indeed a value. Remark . We also note that for each closed term M , the set TPaths( M ) is countable.The next definition we introduce is crucial for the proof of strong adequacy. Definition 74.
Given a relation ⊳ eX,A ∈ ValRel(
X, A, e ) and a term · ⊢ M : A , let S ( ⊳ eX,A ; M ) be the Scott-closure in DCPO M (1 , X ) of the set S ( ⊳ eX,A ; M ) def = (X π ∈ F P ( π ) v π | F ⊆ TPaths( M ) , F is finite and v π ⊳ eX,A V π for each π ∈ F ) . (8)In other words, S ( ⊳ eX,A ; M ) is the smallest Scott-closed subset of DCPO M (1 , X ) which contains all morphisms of the formin (8). For a subset U ⊆ DCPO M (1 , X ) , we write U to indicate its Scott-closure in DCPO M (1 , X ) . Lemma 75.
For any value V , we have S ( ⊳ eX,A ; V ) = { v | v ⊳ eX,A V } ∪ { } = { v | v ⊳ eX,A V } ∪ { } . Proof.
This is because all of the sums in (8) are singleton sums or the empty sum.
Lemma 76 ( [12, Lemma 8.4]) . Let Y be a dcpo and let { X i } i ∈ F be a finite collection of dcpo’s. Let f : Q i X i → Y be aScott-continuous function. Let C Y be a Scott-closed subset of Y . Let U i ⊆ X i be arbitrary subsets, such that f ( Q i U i ) ⊆ C Y .Then f ( Q i U i ) ⊆ C Y , where U i is the Scott-closure of U i in X i . Lemma 77.
Let ⊳ e X ,A and ⊳ e X ,A be two logical relations and · ⊢ M : A a term. Assume that g : X . → X is a morphism,such that v ⊳ e X ,A V implies g (cid:18) v ∈ S ( ⊳ e X ,A ; V ) , for any V ∈ Val( M ) . If m ∈ S ( ⊳ e X ,A ; M ) , then g (cid:18) m ∈ S ( ⊳ e X ,A ; M ) . roof. By Lemma 76, it suffices to show that g (cid:18) X π ∈ F P ( π ) v π ! ∈ S ( ⊳ e X ,A ; M ) for any choice of finite F ⊆ TPaths( M ) and morphisms v π with v π ⊳ e X ,A V π . We have g (cid:18) X π ∈ F P ( π ) v π = X π ∈ F P ( π )( g (cid:18) v π ) , where the equality follows by linearity of ( g (cid:18) − ) . Next, for each v π , by assumption g (cid:18) v π ∈ S ( ⊳ e X ,A ; V π ) . Therefore byapplying Lemma 75, it follows g (cid:18) v π ∈ { v ′ | v ′ ⊳ e X ,A V π } ∪ { } . Now, consider the function X π ∈ F P ( π )( − ) : Y | F | DCPO M (1 , X ) → DCPO M (1 , X ) . This function is continuous, so by Lemma 76 again, it suffices to show that X π ∈ F P ( π ) m ′ π = X π ∈ Fm ′ π =0 P ( π ) m ′ π ∈ S ( ⊳ e X ,A ; M ) , where either m ′ π = 0 or m ′ π ⊳ e X ,A V π for each π ∈ F . Since the summands where m ′ π = 0 do not affect the sum, it sufficesto show that this is true under the assumption that m ′ π ⊳ e X ,A V π . But this is true by definition of S ( ⊳ e X ,A ; M ) .Next, we define important closure relations which we use for terms. Definition 78. If ⊳ eX,A ∈ ValRel(
X, A, e ) , let ⊳ eX,A ⊆ DCPO M (1 , X ) × Prog( A ) be the relation defined by m ⊳ eX,A M iff m ∈ S ( ⊳ eX,A ; M ) . Lemma 79.
For any term · ⊢ M : A and ⊳ eX,A ∈ ValRel(
X, A, e ) , the set ( − ) ⊳ eX,A M is a Scott-closed subset of DCPO M (1 , X ) . Proof.
This follows immediately by definition, because S ( ⊳ eX,A ; M ) is Scott-closed. Lemma 80.
Let C be a Scott-closed subset of a dcpo X . Let W def = { δ x | x ∈ C } ⊆ M X and let W be the Scott-closure of W in M X. Then, δ y ∈ W iff y ∈ C. Proof.
The “if” direction is straightforward. The “only if” direction is trivial when C = X . We now prove the case that C is a proper subset of X , and let U be the complement of C . Hence U is a nonempty Scott open subset of X . Let us assumethat δ y ∈ W but y ∈ U , then we know that [ U > def = { ν ∈ M X | ν ( U ) > } is a Scott open subset of M X containing δ y ,hence we would have that [ U > ∩ W = ∅ since by assumption δ y ∈ W . However, this is impossible since for any x ∈ C , δ x ( U ) = 0 . Lemma 81.
Let X be a dcpo, let v ∈ TD (1 , X ) and let V be a value. Then v ⊳ eX,A V iff v ⊳ eX,A V. Proof.
The left-to-right direction follows immediately by Lemma 75. For the other direction, we first observe that since v ∈ TD (1 , X ) , then v = 0 . Therefore by Lemma 75, it follows v ∈ { w | w ⊳ eX,A V } and then by Lemma 80 we completethe proof. Lemma 82.
For any value · ⊢ V : A and ⊳ eX,A ∈ ValRel(
X, A, e ) , if m ⊳ eX,A V then e (cid:18) m ≤ J V K .Proof. We know m ∈ S ( ⊳ eX,A ; V ) = { v | v ⊳ eX,A V } ∪ { } and clearly e (cid:18) m ≤ J V K is equivalent to ( e (cid:18) m ) ∈ ↓ J V K , whichis a Scott-closed subset. If m = 0 , then the statement is obviously true. So, assume that m ∈ { v | v ⊳ eX,A V } . Compositionwith e is a Scott-continuous function and therefore using Lemma 76, to finish the proof it suffices to show e (cid:18) v ≤ J V K foreach choice of v ⊳ eX,A V . But this is true by assumption on ⊳ eX,A . . Categories of Logical Relations Definition 83.
For any type A , we define a category R ( A ) where: • Each object is a triple ( X, e X , ⊳ X ) , where X is a dcpo, e X : X . → J A K is a morphism in PD e and ⊳ X ∈ ValRel(
X, A, e X ) . • A morphism f : ( X, e X , ⊳ X ) → ( Y, e Y , ⊳ Y ) is a morphism f : X . → Y in PD e , which satisfies the three additionalconditions: – If v ⊳ X V, then f (cid:18) v ⊳ Y V. – If v ⊳ Y V, then f p (cid:18) v ⊳ X V. – e X = e Y (cid:18) f. • Composition and identities coincide with those in PD e . Lemma 84.
For every type A , the category R ( A ) is indeed well-defined.Proof. We have to show that id : ( X, e X , ⊳ X ) → ( X, e X , ⊳ X ) is indeed a morphism in R ( A ) . This follows from Lemma81. Next, we have to show that if f : ( X, e X , ⊳ X ) → ( Y, e Y , ⊳ Y ) and g : ( Y, e Y , ⊳ Y ) → ( Z, e Z , ⊳ Z ) , then we also have g (cid:18) f : ( X, e X , ⊳ X ) → ( Z, e Z , ⊳ Z ) . But this follows by Lemma 77.
Lemma 85.
Let · ⊢ M : A be a term and let g : ( X, e X , ⊳ X ) → ( Y, e Y , ⊳ Y ) be a morphism in R ( A ) . If m ⊳ X M then g (cid:18) m ⊳ Y M . Moreover, if n ⊳ Y N, then g p (cid:18) n ⊳ X N.Proof.
This follows immediately by Lemma 77.
Definition 86.
For every type A , we define the obvious forgetful functor U A : R ( A ) → PD e by U A ( X, e, ⊳ ) = XU A ( f ) = f. Proposition 87.
For each type A , the category R ( A ) has an initial object and all ω -colimits. Furthermore, the forgetful functor U A : R ( A ) → PD e preserves and reflects ω -colimits (and also the initial objects).Proof. We begin with the initial object.
Initial object : For any dcpo’s X and Y , we write X,Y : X . → Y for the zero morphism in PD . Notice that ∅ ,X is anembedding with projection counterpart given by X, ∅ . The object ( ∅ , ∅ , J A K , ∅ ) is initial in R ( A ) . Indeed, let ( X, e X , ⊳ X ) be any other object of R ( A ) . It suffices to show that ∅ ,X : ( ∅ , ∅ , J A K , ∅ ) → ( X, e X , ⊳ X ) is a morphism in R ( A ) , because if it exists, then it is clearly unique. The first and thirdconditions of Definition 83 are trivially satisfied. The second condition is also satisfied, because p ∅ ,X (cid:18) v = 0 , ∅ , which isthe least (and only) element in DCPO M (1 , ∅ ) and this element is contained in every relation ⊳ Y , including ∅ . The diagram : For the rest of the proof, let D : ω → R ( A ) be an ω -diagram in R ( A ) . Let D ( i ) = ( X i , e i , ⊳ i ) and let D ( i ≤ j ) = f i,j . Construction of the colimiting object : Consider the ω -diagram U D in PD e . This category has all ω -colimits, so let τ : U D ⇒ X ω be its colimiting cocone. Next, consider the cocone ǫ : U D ⇒ J A K defined by ǫ i def = e i : X i . → J A K . Let e ω : X ω . → J A K be the unique cocone morphism e ω : τ → ǫ induced by the colimit τ in PD e . We now define a relation ⊳ ω ∈ ValRel( X ω , A, e ω ) by: v ⊳ ω V iff ∀ k ∈ N . τ pk (cid:18) v ⊳ k V. We have to show that ⊳ ω ∈ ValRel( X ω , A, e ω ) , as claimed above. We begin with downwards-closure. Assume v ⊳ ω V andthat v ′ ≤ v in TD (1 , X ω ) . Then, ∀ k ∈ N . τ pk (cid:18) v ⊳ k V and therefore τ pk (cid:18) v ′ ⊳ k V , because ( − ⊳ k V ) is downwards-closedand so by definition v ′ ⊳ ω V, as required.Next, we show that ( − ⊳ ω V ) preserves directed suprema and is therefore Scott-closed in TD (1 , X ω ) . Assume that { v d } d ∈ D is a directed set, such that v d ⊳ ω V for each d ∈ D . Therefore, ∀ k ∈ N . ∀ d ∈ D. τ pk (cid:18) v d ⊳ k V. Scott-closure of ( − ⊳ k V ) implies that τ pk (cid:18) (sup d ∈ D v d ) = sup d ∈ D τ pk (cid:18) v d ⊳ k V holds for all k ∈ N . Therefore, by definition sup d ∈ D v d ⊳ ω V. We also have to show that if v ⊳ ω V , then e ω (cid:18) v ≤ J V K . If v ⊳ ω V , then ∀ k ∈ N . τ pk (cid:18) v ⊳ k V and so by Lemma 82 weget e k (cid:18) τ pk (cid:18) v ≤ J V K . But e k (cid:18) τ pk (cid:18) v = e ω (cid:18) τ k (cid:18) τ pk (cid:18) v. The limit-colimit coincidence theorem in the category PD , showsthat this forms an increasing sequence and that J V K ≥ sup k ∈ N e ω (cid:18) τ k (cid:18) τ pk (cid:18) v = e ω (cid:18) (cid:18) sup k ∈ N τ k (cid:18) τ pk (cid:19) (cid:18) v = e ω (cid:18) id (cid:18) v = e ω (cid:18) v, as required. We will show that the object ( X ω , e ω , ⊳ ω ) is the colimiting object of D in R ( A ) . Before we can do this, we firsthave to construct the colimiting cocone in R ( A ) . onstruction of the colimiting cocone : We show that τ : D ⇒ X ω is a cocone in R ( A ) . The commutativity requirementsare clearly satisfied, so it suffices to show that each τ i : X i . → X ω is a morphism τ i : ( X i , e i , ⊳ i ) → ( X ω , e ω , ⊳ ω ) in R ( A ) .Towards that end, assume that v ⊳ i V . We have to show that τ i (cid:18) v ⊳ ω V , but by Lemma 81, it suffices to show that τ i (cid:18) v ⊳ ω V . Showing this is equivalent to showing that ∀ k ∈ N . τ pk (cid:18) τ i (cid:18) v ⊳ k V. For any k ≥ i , we get: τ pk (cid:18) τ i (cid:18) v = τ pk (cid:18) τ k (cid:18) f i,k (cid:18) v = f i,k (cid:18) v ⊳ k V because f i,k is a morphism f i,k : ( X i , e i , ⊳ i ) → ( X k , e k , ⊳ k ) and v ⊳ i V by assumption. For any k < i , we get: τ pk (cid:18) τ i (cid:18) v = f pk,i (cid:18) τ pi (cid:18) τ i (cid:18) v = f pk,i (cid:18) v ⊳ k V because f k,i is a morphism f k,i : ( X k , e k , ⊳ k ) → ( X i , e i , ⊳ i ) and v ⊳ i V by assumption (and Lemma 85).To show that τ i : ( X i , e i , ⊳ i ) → ( X ω , e ω , ⊳ ω ) is a morphism, we have to show that if v ⊳ ω V, then also τ pi (cid:18) v ⊳ i V. Butthis is true by definition of ⊳ ω . Finally we have to show that e i = e ω (cid:18) τ i . But this is true by construction of e ω .Therefore, τ : D ⇒ ( X ω , e ω , ⊳ ω ) is indeed a cocone of D in R ( A ) . Couniversality of the cocone : For the rest of the proof, assume that α : D ⇒ ( Y, e y , ⊳ Y ) is some other cocone of D in R ( A ) . Next, consider the cocone
U α in PD e and let a : X ω . → Y be the unique cocone morphism a : U τ → U α induced bythe colimit in PD e . By the limit-colimit coincidence theorem in PD , we get a = a (cid:18) id = a (cid:18) sup i ∈ N τ i (cid:18) τ pi = sup i ∈ N a (cid:18) τ i (cid:18) τ pi = sup i ∈ N α i (cid:18) τ pi We will show that a : ( X ω , e ω , ⊳ ω ) → ( Y, e Y , ⊳ Y ) is a morphism in R ( A ) . Towards this end, assume that v ⊳ ω V . Then ∀ k ∈ N . τ pk (cid:18) v ⊳ k V and therefore α k (cid:18) τ pk (cid:18) v ⊳ Y V, because by assumption α k : ( X k , e k , ⊳ k ) → ( Y, e y , ⊳ Y ) . Since ( − ⊳ Y V ) is closed under suprema, it follows sup k ∈ N α k (cid:18) τ pk (cid:18) v = (cid:18) sup k ∈ N α k (cid:18) τ pk (cid:19) (cid:18) v = a (cid:18) v ⊳ Y V, which shows that a satisfies one of the requirements for being a morphism in R ( A ) . For the second requirement, assume that v ⊳ Y V. Then, ∀ k ∈ N . α pk (cid:18) v ⊳ k V , by assumption on α k . The same argumentshows that ∀ k ∈ N . τ k (cid:18) α pk (cid:18) v ⊳ ω V , because τ k is also a morphism in the category. Since ( − ⊳ ω V ) is closed undersuprema, we get: sup k ∈ N τ k (cid:18) α pk (cid:18) v = sup k ∈ N τ k (cid:18) τ pk (cid:18) a p (cid:18) v = (cid:18) sup k ∈ N τ k (cid:18) τ pk (cid:19) (cid:18) a p (cid:18) v = a p (cid:18) v ⊳ ω V as required.For the third requirement, we have to show that e ω = e Y (cid:18) a. By assumption on the cone α : D ⇒ ( Y, e Y , ⊳ Y ) , we havethat ∀ i ∈ N . e i = e Y (cid:18) α i and by construction of a , we know α i = a (cid:18) τ i . Therefore ∀ i ∈ N . e i = e Y (cid:18) a (cid:18) τ i . However, e ω is by construction the unique morphism in PD e , such that ∀ i. e i = e ω (cid:18) τ i , which shows that e ω = e Y (cid:18) a, as required.Therefore, we have shown that a : ( X ω , e ω , ⊳ ω ) → ( Y, e Y , ⊳ Y ) is indeed a morphism in R ( A ) . That a : τ → α is the unique cocone morphism is now obvious, because if a ′ : τ → α is another one, then U a and
U a ′ areboth cocone morphisms between U τ and
U α in PD e and therefore a = U a = U a ′ = a ′ . Therefore, τ : D ⇒ ( X ω , e ω , ⊳ ω ) is indeed the colimiting cocone of D in R ( A ) , which shows that R ( A ) has all ω -colimits. U A preserves ω -colimits : Assume that the cocone α : D ⇒ ( Y, e y , ⊳ Y ) from above is colimiting in R ( A ) . But, we knowthat τ : D ⇒ ( X ω , e ω , ⊳ ω ) is also a colimiting cocone of D . Therefore, there exists a unique cocone isomorphism i : τ → α. Then,
U i : U τ → U α is a cocone isomorphism in PD e . However, by construction, U τ is a colimiting cocone of
U D in PD e and therefore so is U α . U A reflects ω -colimits : Assume that the cocone α : D ⇒ ( Y, e y , ⊳ Y ) from above is such that U α : U D ⇒ Y iscolimiting in PD e . Then the morphism a : X ω . → Y from above is an isomorphism in PD e . We have already shown that a : ( X ω , e ω , ⊳ ω ) → ( Y, e Y , ⊳ Y ) is a morphism in R ( A ) . Thus, to finish the proof, it suffices to show that a − is a morphismin R ( A ) in the opposite direction. But this is obviously true, because a − = a p and ( a − ) p = a and we have shown abovethat these morphisms satisfy the logical requirements and clearly e Y = e ω (cid:18) a − . Next, we introduce important relation constructors and some new notation.
Notation 88.
Given morphisms m i : 1 . → X i , for i ∈ { , . . . , n } , we define hh m , . . . , m n ii def = ( m . × · · · . × m n ) (cid:18) J h id , . . . , id i : 1 . → X × · · · × X n . Note that τ i (cid:18) v is a morphism of TD , because v is one and because τ i ∈ PD e which is a subcategory of TD . otation 89. Given morphisms x : 1 . → X and f : 1 . → [ X . → Y ] in DCPO M , let f [ x ] : 1 . → Y be the morphism defined by f [ x ] def = ǫ (cid:18) ( f . × x ) (cid:18) J h id , id i . Definition 90 (Relation Constructions) . We define relation constructors: • If ⊳ e X ,A ∈ ValRel( X , A , e ) and ⊳ e X ,A ∈ ValRel( X , A , e ) , define ( ⊳ e X ,A + ⊳ e X ,A ) ∈ ValRel( X + X , A + A , e . + e ) by: J in i (cid:18) v ( ⊳ e X ,A + ⊳ e X ,A ) in i V iff v ⊳ e i X i ,A i V ( for i ∈ { , } ) . • If ⊳ e X ,A ∈ ValRel( X , A , e ) and ⊳ e X ,A ∈ ValRel( X , A , e ) , define ( ⊳ e X ,A × ⊳ e X ,A ) ∈ ValRel( X × X , A × A , e . × e ) by: hh v , v ii ( ⊳ e X ,A × ⊳ e X ,A ) ( V , V ) iff v ⊳ e X ,A V and v ⊳ e X ,A V . • If ⊳ e X ,A ∈ ValRel( X , A , e ) and ⊳ e X ,A ∈ ValRel( X , A , e ) , define ( ⊳ e X ,A → ⊳ e X ,A ) ∈ ValRel([ X . → X ] , A → A , J [ e p . → e ]) by: f ( ⊳ e X ,A → ⊳ e X ,A ) λx.M iff J [ e p . → e ] (cid:18) f ≤ J λx.M K and ∀ ( v ⊳ e X ,A V ) . f [ v ] ⊳ e X ,A ( λx.M ) V. Lemma 91.
The assignments in Definition 90 are indeed well-defined.Proof.
Straightforward verification.Next, a simple lemma that we use later.
Lemma 92.
Assume we are given morphisms f : 1 . → [ C . → D ] , h : A . → C, g : D . → B and v : 1 . → A. Then ( J [ h . → g ] (cid:18) f )[ v ] = g (cid:18) f [ h (cid:18) v ] . Proof. ( J [ h . → g ] (cid:18) f )[ v ] = ǫ (cid:18) (( J [ h . → g ] (cid:18) f ) . × v ) (cid:18) J h id , id i ( Definition )= ǫ (cid:18) ( J [ h . → g ] . × id ) (cid:18) ( f . × v ) (cid:18) J h id , id i = ǫ (cid:18) ( J [ id . → g ] . × id ) (cid:18) ( J [ h . → id ] . × id ) (cid:18) ( f . × v ) (cid:18) J h id , id i = g (cid:18) ǫ (cid:18) ( J [ h . → id ] . × id ) (cid:18) ( f . × v ) (cid:18) J h id , id i ( Naturality of ǫ )= g (cid:18) ǫ (cid:18) ( id . × h ) (cid:18) ( f . × v ) (cid:18) J h id , id i ( Parameterised adjunction [44, pp.102] )= g (cid:18) f [ h (cid:18) v ] ( Definition ) Notation 93.
Throughout the rest of the paper we shall write ( − . → e − ) def = [ − . → − ] J e : PD e × PD e → PD e . That is, wejust introduce a more concise notation for the functor [ − . → − ] J e from Proposition 62.The next definition is crucial. Given two logical relations, it is used to define the product, coproduct and function spacelogical relations. Moreover, this is done in a functorial sense on the categories R ( A ) . Definition 94.
Let A and B be types. We define covariant functors in the following way (recall Definition 90):1) × A,B : R ( A ) × R ( B ) → R ( A × B ) by ( X, e X , ⊳ X ) × A,B ( Y, e Y , ⊳ Y ) def = ( X × Y, e X . × e e Y , ⊳ X × ⊳ Y ) f × A,B g def = f . × e g + A,B : R ( A ) × R ( B ) → R ( A + B ) by ( X, e X , ⊳ X ) + A,B ( Y, e Y , ⊳ Y ) def = ( X + Y, e X . + e e Y , ⊳ X + ⊳ Y ) f + A,B g def = f . + e g → A,B : R ( A ) × R ( B ) → R ( A → B ) by ( X, e X , ⊳ X ) → A,B ( Y, e Y , ⊳ Y ) def = ([ X . → Y ] , e X . → e e Y , ⊳ X → ⊳ Y ) f → A,B g def = f . → e g roposition 95. Each of the functors from Definition 94 is well-defined.Proof.
We will show the case for function types which is the most complicated. The other cases follow by a straightforwardverification using similar arguments.
Function types : Let f : ( X , e X , ⊳ X ) → ( Y , e Y , ⊳ Y ) f : ( X , e X , ⊳ X ) → ( Y , e Y , ⊳ Y ) We have to show f . → e f : ( X . → e X , e X . → e e X , ⊳ X → ⊳ X ) → ( Y . → e Y , e Y . → e e Y , ⊳ Y → ⊳ Y ) is a morphism in R ( A → B ) .First, we show that f . → e f respects the embedding component. Indeed: e X . → e e X = ( e Y (cid:18) f ) . → e ( e Y (cid:18) f ) = ( e Y . → e e Y ) (cid:18) ( f . → e f ) . Next, assume that v ( ⊳ X → ⊳ X ) V . Assume further that v ′ ⊳ Y V ′ . Then, clearly f p (cid:18) v ′ ⊳ X V ′ . If f p (cid:18) v ′ = 0 , then it triviallyfollows that v [ f p (cid:18) v ′ ] = 0 ⊳ X V V ′ . Otherwise, f p (cid:18) v ′ ∈ TD and so f p (cid:18) v ′ ⊳ X V ′ and therefore v [ f p (cid:18) v ′ ] ⊳ X V V ′ . Inall cases, v [ f p (cid:18) v ′ ] ⊳ X V V ′ and therefore f (cid:18) v [ f p (cid:18) v ′ ] ⊳ Y V V ′ . But then, by Lemma 92 we have: f (cid:18) v [ f p (cid:18) v ′ ] = ( J [ f p . → f ] (cid:18) v )[ v ′ ] = (( f . → e f ) (cid:18) v )[ v ′ ] ⊳ Y V V ′ . Furthemore ( e Y . → e e Y ) (cid:18) ( f . → e f ) (cid:18) v = ( e X . → e e X ) (cid:18) v ≤ J V K and therefore by definition ( f . → e f ) (cid:18) v ( ⊳ Y → ⊳ Y ) V and therefore also ( f . → e f ) (cid:18) v ( ⊳ Y → ⊳ Y ) V , as required.For the other direction, assume that v ( ⊳ Y → ⊳ Y ) V . Assume further that v ′ ⊳ X V ′ . Then, clearly f (cid:18) v ′ ⊳ Y V ′ . If f (cid:18) v ′ = 0 , then it trivially follows that v [ f (cid:18) v ′ ] = 0 ⊳ Y V V ′ . Otherwise, f (cid:18) v ′ ∈ TD and so f (cid:18) v ′ ⊳ Y V ′ and therefore v [ f (cid:18) v ′ ] ⊳ Y V V ′ . In all cases, v [ f (cid:18) v ′ ] ⊳ Y V V ′ and therefore f p (cid:18) v [ f (cid:18) v ′ ] ⊳ X V V ′ . But then, by Lemma 92 we have: f p (cid:18) v [ f (cid:18) v ′ ] = ( J [ f . → f p ] (cid:18) v )[ v ′ ] = (( f . → e f ) p (cid:18) v )[ v ′ ] ⊳ X V V ′ . Furthemore ( e X . → e e X ) (cid:18) ( f . → e f ) p (cid:18) v = J [( e X ) p . → e X ] (cid:18) J [ f . → f p ] (cid:18) v = J [( f (cid:18) ( e X ) p ) . → ( e X (cid:18) f p )] (cid:18) v ≤ J [( f (cid:18) ( e X ) p ) . → e Y ] (cid:18) v ≤ J [( e Y ) p . → e Y ] (cid:18) v ≤ J V K . If ( f . → e f ) p (cid:18) v ∈ TD , then ( f . → e f ) p (cid:18) v ( ⊳ X → ⊳ X ) V by definition. Otherwise, ( f . → e f ) p (cid:18) v = 0 and then trivially ( f . → e f ) p (cid:18) v = 0 ( ⊳ X → ⊳ X ) V . Therefore, in all cases ( f . → e f ) p (cid:18) v ( ⊳ X → ⊳ X ) V , as required.Therefore, the functor → A,B is indeed well-defined.Observe that Definition 94 lifts the functors that we use to interpret our types in the category
DCPO M to the categories R ( A ) . Next, we show that the functors we just defined are also suitable for forming (parameterised) initial algebras. Proposition 96.
For ⋆ ∈ {× , + , →} , for all types A and B , the functor ⋆ A,B : R ( A ) × R ( B ) → R ( A ⋆ B ) is ω -cocontinuousand the following diagram: R ( A ) × R ( B ) R ( A ⋆ B ) ⋆ A,B PD e × PD e PD e . ⋆ e U A⋆B U A × U B commutes.roof. Commutativity of the diagram is immediate from the definitions. To see ω -cocontinuity, let D be an ω -diagram in R ( A ) × R ( B ) and let τ be its colimiting cocone. Because the functors U A , U B and . ⋆ e are ω -cocontinuous, it follows that : ( . ⋆ e ◦ U A × U B ) τ is colimiting in PD e = ⇒ ( U A⋆B ◦ ⋆ A,B ) τ is colimiting in PD e (Commutativity of the above diagram) = ⇒ ⋆ A,B τ is colimiting in R ( A ⋆ B ) ( U reflects ω -colimits)which shows that ⋆ A,B is ω -cocontinuous.Next, we establish an isomorphism between the categories R ( µX.A ) and R ( A [ µX.A/X ]) . Definition 97.
We define constructors for folding and unfolding logical relations as follows: • If ⊳ eX,A [ µY.A/Y ] ∈ ValRel(
X, A [ µY.A/Y ] , e ) , define ( I µY.A ⊳ eX,A [ µY.A/Y ] ) ∈ ValRel(
X, µY.A, fold (cid:18) e ) by: v ( I µY.A ⊳ eX,A [ µY.A/Y ] ) fold V iff v ⊳ eX,A [ µY.A/Y ] V. • If ⊳ eX,µY.A ∈ ValRel(
X, µY.A, e ) , define ( E µY.A ⊳ eX,µY.A ) ∈ ValRel(
X, A [ µY.A/Y ] , unfold (cid:18) e ) by: v ( E µY.A ⊳ eX,µY.A )) V iff v ⊳ eX,µY.A fold V. Proposition 98.
The above assignments are indeed well-defined.Proof.
Straightforward verification.
Proposition 99.
For every type · ⊢ µX.A, we have an isomorphism of categories I µX.A : R ( A [ µX.A/X ]) ∼ = R ( µX.A ) : E µX.A , where the functors are defined by I µX.A : R ( A [ µX.A/X ]) → R ( µX.A ) E µX.A : R ( µX.A ) → R ( A [ µX.A/X ]) I µX.A ( Y, e, ⊳ ) = ( Y, fold (cid:18) e, I µX.A ⊳ ) E µX.A ( Y, e, ⊳ ) = ( Y, unfold (cid:18) e, E µX.A ⊳ ) I µX.A ( f ) = f E µX.A ( f ) = f Proof.
The proof is essentially the same as [49, Lemma 7.23], with one extra proof obligation, namely we have to show thatour functorial assignments respect the embedding components. But this is obviously true.This finishes the categorical development of the categories R ( A ) . D. Augmented Interpretation of Types
We have now established sufficient categorical structure in order to construct parameterised initial algebras in the categories R ( A ) . Furthermore, we have sufficient structure to also define an augmented interpretation of types in these categories. Themain idea behind providing the augmented interpretation is to show how to pick out the logical relations we need from allthose that exist in the categories R ( A ) . Notation 100.
Given any type context
Θ = X , . . . , X n and closed types · ⊢ C i with i ∈ { , . . . , n } , we shall write ~C for C , . . . , C n and we also write [ ~C/ Θ] for [ C /X , . . . , C n /X n ] . Definition 101.
For any type Θ ⊢ A and closed types ~C , we define their augmented interpretation to be the functor k Θ ⊢ A k ~C : R ( C ) × · · · × R ( C n ) → R ( A [ ~C/ Θ]) defined by induction on the derivation of Θ ⊢ A : k Θ ⊢ Θ i k ~C := Π i k Θ ⊢ A ⋆ B k ~C := ⋆ A [ ~C/ Θ] ,B [ ~C/ Θ] ◦ hk Θ ⊢ A k ~C , k Θ ⊢ B k ~C i ( for ⋆ ∈ { + , × , →} ) k Θ ⊢ µX.A k ~C := (cid:16) I µX.A [ ~C/ Θ] ◦ k Θ , X ⊢ A k ~C,µX.A [ ~C/ Θ] (cid:17) ♯ , where the ( − ) ♯ operation is from Definition 43. roposition 102. Each functor k Θ ⊢ A k ~C is well-defined and ω -cocontinuous. Moreover, the following diagram: R ( C ) × · · · × R ( C n ) R ( A [ ~C/ Θ]) k Θ ⊢ A k ~C PD e × · · · × PD e PD e J Θ ⊢ A K U A [ ~C/ Θ] U C × · · · × U C n commutes.Proof. The proof is essentially the same as [49, Proposition 7.26].Next, a corollary which shows that parameterised initial algebras for our type expressions are constructed in the same wayin both categories.
Corollary 103.
The 2-categorical diagram: R ( C ) × · · · × R ( C n ) R ( A [ ~C/ Θ]) ι PD e × · · · × PD e PD e J Θ , X ⊢ A K ◦ h Id , J Θ ⊢ µX.A K i ι k Θ ⊢ µX.A k ~C J Θ ⊢ µX.A K U A [ ~C/ Θ] U C × · · · × U C n I µX.A [ ~C/ Θ] ◦ k Θ , X ⊢ A k ~C,µX.A [ ~C/ Θ] ◦ h Id , k Θ ⊢ µX.A k ~C i commutes, where ι is the parameterised initial algebra isomorphism (see Definition 43).Proof. The proof is the same as [49, Corollary 7.27].Proposition 102 shows that the first component of the augmented interpretation coincides with the standard interpretation.This is true for all types, including open ones. In the special case for closed types, let k A k def = k· ⊢ A k · ( ∗ ) , where ∗ is theunique object of the terminal category = R ( A ) . Proposition 102 therefore shows that U k A k = J A K , which means that k A k has the form k A k = ( J A K , e, ⊳ ) , where e : J A K . → J A K is some embedding. Next, we show that e = id . In order to do this,we prove a stronger proposition first. We show that the action of the functor k Θ ⊢ A k ~C on the embedding component is alsocompletely determined by the action of J Θ ⊢ A K on embeddings. Proposition 104.
For every functor k Θ ⊢ A k ~C and objects ( X i , e i , ⊳ i ) with i ∈ { , . . . , n } , we have: π e (cid:16) k Θ ⊢ A k ~C (( X , e , ⊳ ) , . . . , ( X n , e n , ⊳ n )) (cid:17) = J Θ ⊢ A K ( e , . . . , e n ) , where for an object ( Z, e Z , ⊳ Z ) in any category R ( B ) , we define π e ( Z, e Z , ⊳ Z ) = e Z . Proof.
By induction on the derivation of Θ ⊢ A. Case Θ i : This is obviously true.
Case A = A ⋆ A , for ⋆ ∈ {× , + , →} : The statement follows easily by induction and the fact that for every pair ofobjects ( Y, e Y , ⊳ Y ) and ( Z, e Z , ⊳ Z ) we have π e (cid:0) ( Y, e Y , ⊳ Y ) ⋆ A ,A ( Z, e Z , ⊳ Z ) (cid:1) = e Y . ⋆ e e Z which follows by definition of the relevant functors. ase µX.A : First we introduce some abbreviations to simplify notation. We define: • T def = k Θ , X ⊢ A k ~C,µX.A [ ~C/ Θ] . • H def = J Θ , X ⊢ A K . • I def = I µX.A [ ~C/ Θ] . • ( X, e, ⊳ ) def = (( X , e , ⊳ ) , . . . , ( X n , e n , ⊳ n )) . • X def = ( X , . . . , X n ) . • e def = ( e , . . . , e n ) .Now, let ( Y, e Y , ⊳ Y ) def = ( I ◦ T ) ♯ ( X, e, ⊳ ) . To finish the proof, we have to show that H ♯ ( e ) = e Y . From Proposition 102we know that Y = H ♯ ( X ) . From Corollary 103, we have a parameterised initial algebra isomorphism ι : I T (cid:16) ( X, e, ⊳ ) , ( H ♯ X, e Y , ⊳ Y ) (cid:17) → ( H ♯ X, e Y , ⊳ Y ) (9)which is also a parameterised initial algebra isomorphism ι : H (cid:16) X, H ♯ X (cid:17) → H ♯ X (10)in PD e . By the induction hypothesis for T and H and Proposition 102, we get T (cid:16) ( X, e, ⊳ ) , ( H ♯ X, e Y , ⊳ Y ) (cid:17) = (cid:16) H ( X, H ♯ X ) , H ( e , e Y ) , ◭ (cid:17) , where ◭ is some (unimportant) logical relation. Therefore by (9) and definition of I , we get that ι : (cid:16) H ( X, H ♯ X ) , fold (cid:18) H ( e , e Y ) , I ◭ (cid:17) → ( H ♯ X, e Y , ⊳ Y ) (11)is an isomorphism with the indicated type. This means that in the category PD e , we have: fold (cid:18) H ( e , e Y ) = e Y (cid:18) ι (12)where we already know that ι = ι X ,...,X n is the parameterised initial algebra in PD e of H . But, by definition, so is fold andin fact fold = ι J C K ,..., J C n K . However, H ♯ e is the unique morphism, such that ι J C K ,..., J C n K (cid:18) H ( e , H ♯ e ) = H ♯ e (cid:18) ι X ,...X n which is the universal property of a parameterised initial algebra (see [49, Remark 4.6]) and therefore by equation (12) itfollows that e Y = H ♯ e , as required. Corollary 105.
For every closed type A , we have k A k = ( J A K , id J A K , ⊳ A ) for some logical relation ⊳ A . Proof.
We already know that the first component is J A K . For the second component, the previous proposition shows that π e k A k = π e k· ⊢ A k · ( ∗ ) = J · ⊢ A K (id ∗ ) = id J A K , where ∗ denotes the empty tuple of objects and id ∗ the empty tuple ofembeddings.Finally, we want to show that the third component of k A k is the logical relation that we need to carry out the adequacyproof. For this, we have to prove a substitution lemma first. Lemma 106 (Substitution) . For any types Θ , X ⊢ A and Θ ⊢ B and closed types C , . . . , C n , we have: k Θ ⊢ A [ B/X ] k ~C = k Θ , X ⊢ A k ~C,B [ ~C/ Θ] ◦ h Id , k Θ ⊢ B k ~C i . Proof.
The proof is the same as [49, Lemma 7.30].For each type A , we have now provided an augmented interpretation k A k of A in the category R ( A ) . The interpretation k−k satisfies all the fundamental properties of J − K , as we have now shown. It should now be clear that this augmented interpretationis true to its name, because it carries strictly more information compared to the standard interpretation of types. The additionalinformation that k A k carries is precisely the logical relation that we need at type A , as we show in the next subsection. . Existence of the Logical Relations We can now show that the logical relations we need for the adequacy proof exist.
Theorem 107.
For each closed type A , there exist formal approximation relations: ⊳ A ⊆ TD (1 , J A K ) × Val( A ) ⊳ A ⊆ DCPO M (1 , J A K ) × Prog( A ) which satisfy the following properties: (A1) J in i (cid:18) v ⊳ A + A in i V iff v ⊳ A i V , where i ∈ { , } . (A2) hh v , v ii ⊳ A × A ( V , V ) iff v ⊳ A V and v ⊳ A V . (A3) f ⊳ A → B λx.M iff f ≤ J λx.M K and ∀ ( v ⊳ A V ) . f [ v ] ⊳ B ( λx.M ) V. (A4) v ⊳ µX.A fold V iff unfold (cid:18) v ⊳ A [ µX.A/X ] V . (B) m ⊳ A M iff m ∈ S ( ⊳ A ; M ) , where S ( ⊳ A ; M ) is the Scott-closure in DCPO M (1 , J A K ) of the set S ( ⊳ A ; M ) def = ( X π ∈ F P ( π ) v π | F ⊆ TPaths( M ) , F is finite and v π ⊳ A V π for each π ∈ F ) ( see Definition 72 ) . (C1) If v ⊳ A V , then v ≤ J V K . (C2) ( − ⊳ A V ) is a Scott-closed subset of TD (1 , J A K ) . (C3) If m ⊳ A M , then m ≤ J M K . (C4) ( − ⊳ A M ) is a Scott-closed subset of DCPO M (1 , J A K ) . (C5) If v ∈ TD (1 , J A K ) and V is a value, then v ⊳ A V iff v ⊳ A V. Proof.
Consider the object k A k ∈ R ( A ) . We have already shown that k A k = ( J A K , id J A K , ⊳ A ) for some logical relation ⊳ A ∈ ValRel( J A K , A, id J A K ) . We now show that ⊳ A satisfies the required properties. Notice that the embedding componentsare just identities.Property (B) is satisfied by construction (Definition 78). Properties (C1) and (C2) are also satisfied by construction (Definition70). Property (C4) is satisfied by construction and property (B). Property (C3) is satisfied, because if m ⊳ A M , then by Corollary67 and property (C1) it follows that S ( ⊳ A ; M ) ⊆ ↓ J M K . The latter set is Scott-closed and therefore m ∈ S ( ⊳ A ; M ) ⊆ ↓ J M K , as required. Property (C5) is satisfied by Lemma 81.Properties (A1), (A2) and (A3) are satisfied, because for ⋆ ∈ { + , × , →} , we have that ⊳ A⋆B = ⊳ A ⋆ ⊳ B and then byDefinition 90.To show that property (A4) is also satisfied, we reason as follows. Consider the isomorphism unfold µX.A : J µX.A K ∼ = J X ⊢ A KJ µX.A K = J A [ µX.A/X ] K : fold µX.A from Definition 51. By Corollary 103 and Lemma 106 (when Θ = · ) it follows that this isomorphism lifts to an isomorphism unfold µX.A : k µX.A k ∼ = I µX.A (cid:0) k X ⊢ A k µX.A ( k µX.A k ) (cid:1) = I µX.A ( k A [ µX.A/X ] k ) : fold µX.A in the category R ( µX.A ) . Expanding definitions, this means we have an isomorphism unfold µX.A : ( J µX.A K , id , ⊳ µX.A ) = k µX.A k∼ = I µX.A ( k A [ µX.A/X ] k )= ( J A [ µX.A/X ] K , fold µX.A , I µX.A ⊳ A [ µX.A/X ] ) : fold µX.A (13)in the category R ( µX.A ) . The notion of morphism in this category (Definition 83), construction of I (Definition 97) andproperty (C5) allow us to conclude that property (A4) is satisfied. Indeed: v ⊳ µX.A fold V = ⇒ unfold µX.A (cid:18) v ( I µX.A ⊳ A [ µX.A/X ] ) fold V = ⇒ unfold µX.A (cid:18) v ⊳ A [ µX.A/X ] V and for the other direction of (A4): unfold µX.A (cid:18) v ⊳ A [ µX.A/X ] V = ⇒ unfold µX.A (cid:18) v ( I µX.A ⊳ A [ µX.A/X ] ) fold V = ⇒ v = fold µX.A (cid:18) unfold µX.A (cid:18) v ⊳ µX.A fold V. . Closure Properties of the Logical Relations Here we establish some important closure properties of the relations ⊳ A from Theorem 107. Lemma 108.
Let · ⊢ M : A be a term and let F be some finite index set. Assume that we are given morphisms m i and terms M i such that m i ⊳ A M i for i ∈ F . Assume further that for each i ∈ F , we are given a reduction path π i ∈ Paths(
M, M i ) ,such that all paths π i are distinct. Then X i ∈ F P ( π i ) m i ⊳ A M. Proof.
By assumption, for every i ∈ F , we know that m i ∈ S ( ⊳ A ; M i ) . Next, consider the function g def = X i ∈ F P ( π i )( − ) : Y | F | DCPO M (1 , J A K ) → DCPO M (1 , J A K ) . This function is Scott continuous and therefore by Lemma 76, it suffices to show that g ( Q i s i ) ∈ S ( ⊳ A ; M ) for any choiceof s i ∈ S ( ⊳ A ; M i ) . Next, for every i ∈ F , let s i = X π ∈ F i P ( π ) v π ! ∈ S ( ⊳ A ; M i ) where F i ⊆ TPaths( M i ) is a finite subset and such that v π ⊳ A V π , for each π ∈ F i . Then, we have g Y i s i ! = X i ∈ F P ( π i ) X π ∈ F i P ( π ) v π ! = X i ∈ F X π ∈ F i ( P ( π i ) · P ( π )) v π = X i ∈ F X π ∈ F i P ( π i π ) v π ∈ S ( ⊳ A ; M ) , where π i π ∈ Paths(
M, V π ) is the path constructed by concatenating the path π i to π . Lemma 109. If m ⊳ A M and n ⊳ A N, then p · m + (1 − p ) · n ⊳ A M or p N. Proof.
This is just a special case of Lemma 108.
Lemma 110.
For i ∈ { , } : if m ⊳ A i M , then J in i (cid:18) m ⊳ A + A in i M. Proof.
Assume, without loss of generality, that i = 1 . By definition we know that m ∈ S ( ⊳ A ; M ) = S ( ⊳ A ; M ) . ByLemma 76, it suffices to show J in (cid:18) X π ∈ F P ( π ) v π ∈ S ( ⊳ A + A ; in M ) for any P π ∈ F P ( π ) v π ∈ S ( ⊳ A ; M ) . Since ( J in (cid:18) − ) is linear, we see J in (cid:18) X π ∈ F P ( π ) v π = X π ∈ F P ( π )( J in (cid:18) v π ) = X π ∈ F P (in ( π ))( J in (cid:18) v π ) ∈ S ( ⊳ A + A ; in M ) , where in ( π ) ∈ Paths( in M, in V π ) is the path constructed by reducing in M to in V π , as specified by π. The membershiprelation is satisfied because by assumption v π ⊳ A V π and then by Theorem 107 (A1). Lemma 111.
Let m ⊳ A + A M . Next, assume that for k ∈ { , } we have terms x k : A k ⊢ N k : B and morphisms n k : J A k K . → J B K , such that for every v k ⊳ A k V k , it is the case that n k (cid:18) v k ⊳ B N k [ V k /x k ] . Then [ n , n ] (cid:18) m ⊳ B case M of in x ⇒ N | in x ⇒ N . Proof.
For brevity, let C be the term C def = ( case M of in x ⇒ N | in x ⇒ N ) . Next, consider the function ([ n , n ] (cid:18) − ) : DCPO M (1 , J A + A K ) → DCPO M (1 , J B K ) . This function is Scott continuous. By Lemma 76, to complete the proof it suffices to show that [ n , n ] (cid:18) m ′ ⊳ B C for any m ′ ∈ S ( ⊳ A + A ; M ) . Towards that end, let m ′ = X π ∈ F P ( π ) v π , here F is finite and where v π ⊳ A + A V π , for each π ∈ F. Let F ⊆ F be the set of paths π such that V π = in V ′ π forsome V ′ π and let F = F − F . Then by Theorem 107 (A1), for each π ∈ F , it follows that V π = in V ′ π and v π = J in (cid:18) v ′ π and v ′ π ⊳ A V ′ π . Similarly, for each π ∈ F , it follows that V π = in V ′ π and v π = J in (cid:18) v ′ π and v ′ π ⊳ A V ′ π . Therefore, weget: [ n , n ] (cid:18) m ′ = [ n , n ] (cid:18) X π ∈ F P ( π )( J in (cid:18) v ′ π ) ! + X π ∈ F P ( π )( J in (cid:18) v ′ π ) !! = X π ∈ F P ( π )( n (cid:18) v ′ π ) ! + X π ∈ F P ( π )( n (cid:18) v ′ π ) ! In the above sums, by assumption, we know that n (cid:18) v ′ π ⊳ B N [ V ′ π /x ] , for each π ∈ F and similarly n (cid:18) v ′ π ⊳ B N [ V ′ π /x ] ,for each π ∈ F . Next, consider the function X π ∈ F P ( π )( − ) ! + X π ∈ F P ( π )( − ) !! : DCPO M (1 , J B K ) | F | × DCPO M (1 , J B K ) | F | → DCPO M (1 , J B K ) . This function is Scott-continuous and by Lemma 76, to complete the proof it suffices to show that X π ∈ F P ( π )( n π ) ! + X π ∈ F P ( π )( n π ) ! ⊳ B C, where n π ∈ S ( ⊳ B ; N [ V ′ π /x ]) for π ∈ F and n π ∈ S ( ⊳ B ; N [ V ′ π /x ]) for π ∈ F are taken to be arbitrary. Towards thisend, let n π = X π ′ ∈ F π P ( π ′ ) v π ′ ∈ S ( ⊳ B ; N [ V ′ π /x ]) n π = X π ′ ∈ F π P ( π ′ ) v π ′ ∈ S ( ⊳ B ; N [ V ′ π /x ]) where F πk is finite and where v π ′ ⊳ B V π ′ , for every π ′ ∈ F πk and where k ∈ { , } . Then, we get X π ∈ F P ( π )( n π ) ! + X π ∈ F P ( π )( n π ) ! == X π ∈ F X π ′ ∈ F π P ( π ) P ( π ′ ) v π ′ + X π ∈ F X π ′ ∈ F π P ( π ) P ( π ′ ) v π ′ = X π ∈ F X π ′ ∈ F π P (case ( π, π ′ )) v π ′ + X π ∈ F X π ′ ∈ F π P (case ( π, π ′ )) v π ′ ∈ S ( ⊳ B ; C ) ⊆ S ( ⊳ B ; C ) , where case ( π, π ′ ) ∈ Paths(
C, V π ′ ) is the path obtained by reducing C to C π def = ( case in V ′ π of in x ⇒ N | in x ⇒ N ) as specified by π , then performing the beta reduction C π −→ N [ V ′ π /x ] and then reducing N [ V ′ π /x ] to V π ′ as specified by π ′ . Similarly for case ( π, π ′ ) . The last sum is now by definition in S ( ⊳ B ; C ) . Lemma 112. If m ⊳ A M and m ⊳ A M then hh m , m ii ⊳ A × A ( M , M ) . Proof.
The map hh− , −ii : DCPO M (1 , J A K ) × DCPO M (1 , J A K ) → DCPO M (1 , J A × A K ) is Scott-continuous in botharguments and therefore by Lemma 76, to complete the proof it suffices to show that hh m ′ , m ′ ii ⊳ A × A ( M , M ) for any m ′ ∈ S ( ⊳ A ; M ) and m ′ ∈ S ( ⊳ A ; M ) .ow, take m ′ = P π ∈ F P ( π ) v π ∈ S ( ⊳ A ; M ) and m ′ = P π ∈ F P ( π ) v π ∈ S ( ⊳ A ; M ) , where F and F arefinite sets, and where v π ⊳ A V π for each π ∈ F and where v π ⊳ A V π for each π ∈ F . We then have: hh m ′ , m ′ ii = hh X π ∈ F P ( π ) v π , X π ∈ F P ( π ) v π ii (14) = X π ∈ F X π ∈ F P ( π ) P ( π ) hh v π , v π ii (15) = X π ∈ F X π ∈ F P (pair( π , π )) hh v π , v π ii (16) ⊳ A × A ( M , M ) . (17)Equation 14 holds by definition. Equation 15 is true since the function hh− , −ii defined above is linear in each component byLemma 38 Item 3. In Equation 16 pair( π , π ) ∈ Paths(( M , M ) , ( V π , V π )) is the path which first reduces ( M , M ) to ( V π , M ) as specified by π and then reduces ( V π , M ) to ( V π , V π ) as specified by π and it is easy to see that Equation16 holds. Finally 17 holds, because v π ⊳ A V π and v π ⊳ A V π by assumption and then by Theorem 107 (A2) we havethat hh v π , v π ii ⊳ ( A ,A ) ( V π , V π ) . Lemma 113. If m ⊳ A × A M then J π i (cid:18) m ⊳ A i π i M , for i ∈ { , } . Proof.
Without loss of generality, we will show the statement for the first projection. In order to avoid notational confusion,we will write pr for π for the projection on the first component in this lemma. We shall use π to range over paths, as inthe other lemmas.Using Lemma 76, to complete the proof it suffices to show that J pr (cid:18) m ′ ⊳ A pr M for any m ′ ∈ S ( ⊳ A × A ; M ) . Towards this end, let m ′ = X π ∈ F P ( π ) v π ∈ S ( ⊳ A × A ; M ) , where F ⊆ TPaths( M ) is finite and where v π ⊳ A × A V π for every π ∈ F . Using Theorem 107 (A2), we see that it mustbe the case v π = hh v π , v π ii and V π = ( V π , V π ) and v π ⊳ A V π and v π ⊳ A V π . Therefore, we have J pr (cid:18) m ′ = J pr (cid:18) X π ∈ F P ( π ) v π = J pr (cid:18) X π ∈ F P ( π ) hh v π , v π ii = X π ∈ F P ( π )( J pr (cid:18) hh v π , v π ii )= X π ∈ F P ( π ) v π = X π ∈ F P (pr ( π )) v π ⊳ A pr M, where pr ( π ) ∈ Paths(pr M, V π ) is the path that reduces pr M to pr ( V π , V π ) as specified by π and then finally performsthe reduction pr ( V π , V π ) −→ V π . Lemma 114. If m ⊳ µX.A M then unfold (cid:18) m ⊳ A [ µX.A/X ] unfold M. Proof.
By Lemma 76, to complete the proof it suffices to show that unfold (cid:18) m ′ ∈ S ( ⊳ A [ µX.A/X ] ; unfold M ) for any m ′ ∈ S ( ⊳ µX.A ; M ) . Towards this end, let m ′ = X π ∈ F P ( π ) v π ∈ S ( ⊳ µX.A ; M ) or some finite F ⊆ TPaths( M ) and where v π ⊳ µX.A V π = fold V ′ π for each π ∈ F . Then we have unfold (cid:18) m ′ = X π ∈ F P ( π )(unfold (cid:18) v π )= X π ∈ F P (unfold( π ))(unfold (cid:18) v π ) ∈ S ( ⊳ A [ µX.A/X ] ; unfold M ) , where unfold( π ) ∈ Paths( unfold
M, V ′ π ) is the path that reduces unfold M to unfold fold V ′ π as specified by π and thenfinally performs the reduction unfold fold V ′ π −→ V ′ π . This last sum satisfies the membership relation, because we know that v π ⊳ µX.A V π = fold V ′ π and then by Theorem 107 (A4) we see that unfold (cid:18) v π ⊳ A [ µX.A/X ] V ′ π , as required. Lemma 115. If m ⊳ A [ µX.A/X ] M then fold (cid:18) m ⊳ µX.A fold M. Proof.
The function (fold (cid:18) − ) : DCPO M (1 , J A [ µX.A/X ] K ) → DCPO M (1 , J µX.A K ) is Scott-continuous and therefore by Lemma 76, to complete the proof it suffices to show that fold (cid:18) m ′ ∈ S ( ⊳ µX.A ; fold M ) for each m ′ ∈ S ( ⊳ A [ µX.A/X ] ; M ) . Towards this end, assume that m ′ = X π ∈ F P ( π ) v π ∈ S ( ⊳ A [ µX.A/X ] ; M ) , where F ⊆ TPaths( M ) is finite and for each π ∈ F we have v π ⊳ A [ µX.A/X ] V π . Therefore, by Theorem 107 (A4) weconclude that fold (cid:18) v π ⊳ µX.A fold V π , for each π ∈ F. Now we finish the proof with the following derivation: fold (cid:18) m ′ = fold (cid:18) X π ∈ F P ( π ) v π = X π ∈ F P ( π )(fold (cid:18) v π )= X π ∈ F P (fold( π ))(fold (cid:18) v π ) ∈ S ( ⊳ µX.A ; fold M ) ⊆ S ( ⊳ µX.A ; fold M ) , where fold( π ) ∈ Paths( fold M, fold V π ) is the path that reduces fold M to fold V π as specified by π. Lemma 116. If m ⊳ A → B M and n ⊳ A N, then m [ n ] ⊳ B M N.
Proof.
Consider the function g : DCPO M (1 , J A → B K ) × DCPO M (1 , J A K ) → DCPO M (1 , J B K ) defined by g ( x, y ) = x [ y ] (see Notation 89). This function is Scott continuous and linear in both arguments. By Lemma 76, to complete the proof itsuffices to show that m ′ [ n ′ ] ⊳ B M N for any m ′ ∈ S ( ⊳ A → B ; M ) and n ′ ∈ S ( ⊳ A ; N ) . Towards that end, let m ′ = X π ∈ F P ( π ) v π ∈ S ( ⊳ A → B ; M ) n ′ = X π ′ ∈ F ′ P ( π ′ ) v π ′ ∈ S ( ⊳ A ; N ) with v π ⊳ A → B V π and v π ′ ⊳ A V π ′ . Then by Theorem 107 (A3) we have that v π [ v π ′ ] ⊳ B V π V π ′ and m ′ [ n ′ ] = X π ∈ F X π ′ ∈ F ′ ( P ( π ) · P ( π ′ )) v π [ v π ′ ]= X ( π,π ′ ) ∈ F × F ′ P (app( π, π ′ )) v π [ v π ′ ] ⊳ B M N (Lemma 108)where app( π, π ′ ) ∈ Paths(
M N, V π V π ′ ) is the path where we first reduce M N to V π N in the same way as in π and then wereduce V π N to V π V π ′ in the same way as in π ′ . Note: in the above sum V π V π ′ is not a value, so Lemma 108 is crucial. . Fundamental Lemma and Strong Adequacy We may now prove the Fundamental Lemma which then easily implies our adequacy result.
Lemma 117 (Fundamental) . Let x : A , . . . , x n : A n ⊢ M : B be a term. Assume further we are given a collection ofmorphisms v i and values V i , such that v i ⊳ A i V i for i ∈ { , . . . , n } . Then: J M K (cid:18) hh ~v ii ⊳ B M [ ~V /~x ] . Proof.
By induction on the derivation of the term M .For the case of lambda abstractions, we reason as follows. Let us assume that the term of the induction hypothesis is x : A , . . . , x n : A n , y : A ⊢ M : B. Let us write l def = J λy.M K (cid:18) hh ~v ii and R def = λy.M [ ~V /~x ] . Observe that l ∈ TD and therefore by Theorem 107 (C5), we mayequivalently show that l ⊳ A → B R. By Theorem 107 (A3), this is in turn equivalent to showing that l ≤ J R K and ∀ ( w ⊳ A W ) . l [ w ] ⊳ B RW.
The inequality is satisfied, because l = J λy.M K (cid:18) hh ~v ii≤ J λy.M K (cid:18) hh ~ J V K ii ( Theorem 107 (C1) )= J R K . ( Lemma 53 ) For the other requirement, assuming that w ⊳ A W , we reason as follows l [ w ] = ( J λy.M K (cid:18) hh ~v ii )[ w ] ( Definition )= ǫ (cid:18) ( J λy.M K . × id ) (cid:18) hh ~v, w ii = ǫ (cid:18) ( J λ ( J M K ) . × id ) (cid:18) hh ~v, w ii ( Definition )= λ − ( λ ( J M K )) (cid:18) hh ~v, w ii (Property of adjunction (5)) = J M K (cid:18) hh ~v, w ii ⊳ B M [ ~V /~x, W/y ] . (Induction Hypothesis)Finally, observe that RW = ( λy.M [ ~V /~x ]) W −→ M [ ~V /~x, W/y ] , i.e. RW beta-reduces to M [ ~V /~x, W/y ] . Therefore by Lemma108 it follows that l [ w ] ⊳ B RW, as required.The case for variables follows immediately by expanding definitions and Theorem 107 (C5).All other cases follow by straightforward induction using closure Lemmas 109 – 116.Adequacy now follows as a corollary of this lemma.
Theorem 118 (Strong Adequacy) . For any closed term · ⊢ M : A , we have J M K = X V ∈ Val( M ) P ( M −→ ∗ V ) J V K . Proof.
Let u def = X V ∈ Val( M ) P ( M −→ ∗ V ) J V K . rom Corollary 67, we know that J M K ≥ u. To finish the proof, we have to show the converse inequality. Next, observe that S ( ⊳ A ; M ) ⊆ ↓ u , which follows from Theorem 107 (C1). To see this, we reason as follows. Taking an arbitrary element of S ( ⊳ A ; M ) as in Theorem 107 (B): X π ∈ F P ( π ) v π ≤ X π ∈ F P ( π ) J V π K ( Theorem 107 (C1) )= X V ∈∪{ V π | π ∈ F } X π ∈ FV π = V P ( π ) J V K ≤ X V ∈∪{ V π | π ∈ F } X π ∈ Paths(
M,V ) P ( π ) J V K = X V ∈∪{ V π | π ∈ F } P ( M −→ ∗ V ) J V K ≤ X V ∈ Val( M ) P ( M −→ ∗ V ) J V K . The set ↓ u is Scott-closed and therefore S ( ⊳ A ; M ) ⊆ ↓ u . By Lemma 117, we know that J M K ⊳ A M. By definition of ⊳ A it follows J M K ∈ S ( ⊳ A ; M ) and therefore J M K ≤ u,u,