Non-deterministic eﬀects in a realizability model

We model non-deterministic eﬀects for Turing computability by working in the assemblies of Kleene’s ﬁrst partial combinatory algebra. Two methods will be discussed, one using equivalence relations on trees and one using topological descriptions of powerdomains. We describe these models for a selection of non-deterministic paradigms: angelic, demonic, convex and probabilistic. Though the ﬁrst approach has a connection to traditional non-deterministic computability, the second approach works better for combining non-determinism with recursion. We establish morphisms from the tree models to the powerdomain models, which are bijective at ground type and give isomorphisms for all but the demonic case. We also see that any of the powerdomain models can be interpreted as a sub-monad of a continuation monad.


Introduction
There are many approaches to understanding computability for higher-order computation [10]. A prominent one uses the notion of assembly on Kleene's first partial combinatory algebra K 1 . This type of computability represents data using numerical codes and models extensional transformations of data using computable realizers. The category of assemblies is cartesian closed and so models higher type computability, which can accommodate computer science features like recursion at higher type [9]. In this paper we study how to model non-deterministic computation in assemblies interpreted in its various forms; angelic, demonic, convex and probabilistic. We thus model computability for higher order non-deterministic computation.
An initial attempt to do something similar was made by Taylor and Phoa in unpublished work from 1990 [12]. A modern perspective on their approach would be to view it as an instance of Power and Plotkin's theory of algebraic effects [14].

Technical background
Kleene's first partial algebra K 1 can be defined as the set N together with the partial algebraic map N × N N denoted (a, b) → ab, giving the result of applying the a-th Turing machine on input b and outputting the result. We write ab ↓ if this terminates with a value, and ab ↑ if the program fails to terminate. Repeated application uses left association, abc = (ab)c. On terms created from constants, variables and applications one has lambda abstraction with weak head reduction.
An assembly A on K 1 is given by a set |A| together with a map || − || A assigning to each element a of |A| a non-empty set of natural numbers called the realizers of a. A (computable) morphism f : A → B between assemblies is given by a map f : |A| → |B| such that there is an n ∈ N with the property that ∀a ∈ |A|, x ∈ ||a|| X : nx ↓ ∧nx ∈ ||f (a)|| A . This gives a cartesian closed category of assemblies Asm on K 1 , where the function object B A consists of the morphisms f : |A| → |B| whose representations are all possible n ∈ N satisfying the above property. This category has finite products and finite co-products (pairing and summation), and: (i) The terminal assembly 1, where |1| = { * } and || * || 1 = N.
(ii) The natural numbers object N with |N | = N and ||n|| N = {n}.
We do however not have a map : Σ N → Σ such that f = ⇔ ∀n : f (n) = . Such a map would need to check for an infinite number of programs whether they terminate, which one can't do in a finite amount of time. By imposing the primitive operations we have similar properties on Σ A for any assembly A. Hence Σ A has the structure of a computable lattice of opens on A as we can interpret a map f : A → Σ as the subset {a ∈ A|f (a) = } of A. We call Σ A the Σ-topology on A, which differs from a classical topology because of its computable nature. Morphisms are automatically continuous with respect to these Σ-topologies. Definition 2.2 Let (−) ⊥ : Asm → Asm be the functor where |A ⊥ | = |A| ∪ {⊥} (disjoint union), with realizers: ||a|| A ⊥ := {n|n0 ↓, n0 ∈ ||a|| A } and ||⊥|| A ⊥ = ||⊥|| Σ This functor adds a bottom element to each assembly. We get that ∀a ∈ |A| : ⊥ ≤ A ⊥ a but not a ≤ A ⊥ ⊥. This functor forms a monad adding partiality; let η ⊥ A : A → A ⊥ denote the appropriate natural transformation. The morphisms N → N ⊥ are precisely the partial computable functions from N to N.
For an assembly A, the regular subobject given by B ⊂ |A| is the assembly B where |B| = B and ||b|| B = ||b|| A for all b ∈ B.

Definition 2.3
Let ω be the regular subobject of Σ N consisting of the morphisms f : N → Σ satisfying: Letω be the regular subobject of Σ N of elements only satisfying condition (i).
These assemblies can be seen as ascending chains in the Σ-order, since for a, b ∈ N ∪ {∞} we have a ≤ ω b precisely when a ≤ b. The topology on ω also induces some interesting continuity properties, as for any f ∈ Σ ω , f ( ∞) = ⇔ ∃ a ∈ ω, f ( a) = .
A map f : ω → A can be seen as an approximation of an element in A, where the sequence {f ( n)} n∈N approximates the limit f ( ∞). Take A iω : A ω → A ω to be the morphism composing maps with the inclusion from ω to ω. The following property of an assembly A implements the completeness property: that every sequence in A has a unique limit.

Definition 2.4 An assembly
So for any sequence f : ω → A on a complete assembly, we can compute its unique limit (A iω ) −1 (f )( ∞). Completeness is an important property, as it is used to derive computable fixed point operators. By [9] we know that the assemblies 1 and N are complete, and that completeness is preserved under (−) ⊥ . For any A, completeness is also preserved under (−) A , as we can take the completion pointwise: we consider F ∈ (X A ) ω as a morphism A → X ω and use completeness of X.
We will investigate assemblies of the form Σ Σ A later on in the paper, so we end this chapter with some properties about them.
For the converse, we can use for a ∈ A the evaluation map w → w(a) in Σ Σ A to show that u(a) ≤ Σ v(a). 2 We write χ V ∈ Σ N for the membership test on V ⊂ N, so χ V (n) = ⇔ n ∈ V . These exist for all finite V 's since we have decidable equality on N . The following result is essentially the Rice-Shapiro theorem from computability theory. Lemma 2.6 For Q ∈ Σ Σ N and u ∈ Σ N such that Q(u) = , there is some finite set V ⊂ N such that ∀n ∈ V, u(n) = and Q(χ V ) = .

Monads of trees
We think of non-deterministic computations as a computation with a series of binary choices until it outputs a result or goes into a loop. We can represent this structure using binary trees. A tree on A is a binary tree whose leaves are labelled with elements from A ⊥ and which may have infinite branches. Each node or leaf of a tree has a location, a binary sequence α ∈ 2 * which describes a path to a node with a series of left and right instructions. We say a tree t on A is constructed by a morphism f : 2 * → (A + 1) ⊥ if for any sequence α ∈ 2 * and any β ∈ 2 * extending or equal to α (written as α β, α is a subsequence of β) we have: (i) If t has a node (not a leaf) at α, then f (α) = η ⊥ (A+1) (inr( * )) (ii) If t has a leaf ⊥ at α, then f (β) = ⊥ (A+1) (iii) If t has a leaf a ∈ |A| at α, then f (β) = η ⊥ (A+1) (inl(a)) Note that a morphism constructing a computable tree is necessarily unique. Any tree which is constructed by some morphism is called computable. The assembly of trees on A, denoted T A, consists of computable trees on A which are represented by realizers of the unique morphism that constructs them. We can represent the algebraic operator or : T A × T A → T A that simply joins two trees t and r into a single tree, which has a base node which branches into both t and r. For a morphism m : A → B, let T m : T A → T B be the morphism that replaces the leaves of a tree t ∈ T A with (m) ⊥ (t). So T (−) forms an endofunctor on Asm.

Proof. For each A we have a morphism η T
A sending x ∈ A to the trivial tree only having a single leaf x. It is realised by the code for λab.a.
The morphism µ T A : T T A → T A is given by replacing leaves with the trees within them. To see it is computable, consider that given a morphism f ∈ ((A+1) 2 * ⊥ +1) 2 * ⊥ and α ∈ 2 * one can search for the smallest subsequence β α such that f (β) = η ⊥ (inl(g)) with g ∈ (A + 1) 2 * ⊥ and then for the smallest sequence γ such that α extends the concatenation βγ and g(γ) = η ⊥ (inl(a)) for some a ∈ A. We can construct a computation that returns η ⊥ (inr(a)) if it finds this a, returns ⊥ if it got into a loop and * if either f (α) = η ⊥ (inr( * )) or g(γ) = η ⊥ (inr( * )) for all checked γ in the procedure. The resulting computation represents µ T A as a map from ((A + 1) 2 * ⊥ + 1) 2 * ⊥ to (A + 1) 2 * ⊥ , the morphisms constructing T T A and T A. Strength can be established by defining for any two assemblies A and B, the map t T A,B : A × T B → T (A × B) by sending (a, t) to the tree created by replacing each leaf l of t with (a, l). This map is computable since it uses some elementary morphisms like pairing and currying on the morphisms constructing the trees. 2 ) or m(Ψ(y))) and m(η ⊥ (inr(a))) = trivial tree with leaf a. Hence m•Ψ is a morphism from B to T A, so T A has the desired properties.2 The given definition has a connection with Turing machine models of nondeterministic computations. The morphisms N → T N correspond to a representation of non-deterministic Turing machines which on an input n will make binary choices until it outputs a value or gets into a loop. Here, no equivalences are taken into account as (0 or 1) is different from (1 or 0). So this model is quite intensional. We derive equivalence relations on T A according to non-deterministic paradigms.
We use the assembly of observations Σ A which describe semi-decidable properties of leaves. For a ∈ A and u ∈ Σ A , we say that a satisfies u if u(a) = .
For any u ∈ Σ A we write u ⊥ ∈ Σ A ⊥ for the morphism with u ⊥ (⊥) = ⊥ and u ⊥ (η ⊥ A (a)) = u(a) for any a ∈ A. Since leaves of trees from T A are elements of A ⊥ , they can be 'tested' by observations in Σ A ⊥ . Definition 3. 3 We say that t, r ∈ T A are lower-equivalent (t ∼ l r) when for any u ∈ Σ A , if either t or r has a leaf a for which u ⊥ (a) = then both have a leaf satisfying u ⊥ .
This corresponds to what is called angelic non-determinism, as it looks at which properties may hold for some possible sequence of choices. Another type, demonic non-determinism checks which properties must hold whatever the choices were. To effectively check this in a finite amount of time, one must furthermore require that the trees are finite.
Definition 3. 4 We say that f, g ∈ T A are upper-equivalent (f ∼ u g) if for any u ∈ Σ A we have, f is finite and all its leaves satisfy u ⊥ if and only if g is finite and all its leaves satisfy u ⊥ . Interpreting the tree as a combination of 50-50 chances (coin-flips), we define a function ℘ : Σ A × T A → [0, 1] which for (t, u) gives the probability that t satisfies u ⊥ . More concretely, let L t u be the set of locations α ∈ 2 * at which t has a leaf satisfying u ⊥ . Then we can define ℘(u, t) := Σ α∈L t u 2 −length(α) . Here length(α) denotes the height of the leaf, so 2 −length(α) is the probability to end up in that leaf.
Maps N → T l (N ) correspond to non-deterministic Turing machines which, for any input n, exhibit corresponding non-deterministic computations. The equivalence relation implements an angelic equivalence by which, for example, the computations 0 and (0 or 1) are considered equivalent. The maps N → T u (N ) corresponds to demonic non-deterministic Turing machines where ⊥ is considered the same as (0 or ⊥). The convex non-deterministic and probabilistic Turing machines are represented respectively by the morphisms N → T c (N ) and N → T p (N ). So each of the tree models can be seen as modelling Turing computability for a particular non-deterministic paradigm.
So for any of the notions of equivalence i ∈ {l, u, c, p} we can define an endofunctor T i (−) on Asm given by T (−)/ ≡ i . The equivalences are preserved under Kleisli lifts (t ≡ r ⇒ f * (t) ≡ f * (r)) as will be illustrated later. They also preserve the algebraic operator or. However, we do not know how to find a cartesian closed subcategory closed under T i that only contains complete objects.
In order to get a model that combines non-determinism with completeness, we look towards complete powerdomains in domain theory. There are many descriptions of powerdomains, each sensitive to the domain theoretical setting. We want to choose the description that suits our setting best.
In Asm, we have structures that can be used to synthetically define a form of computable topology. In particular, Σ has the structure of the Sierpiński space S, and Σ A is a computable analogue to the lattice of open sets on A, just like in topology opens of X can be given by continuous maps X → S.
Described in [16], the lower powerdomain on some preorder X is the set of completely prime upwards closed opens on the lattice of open sets O(X). In [3] this space has been proven to be equivalent to the continuous maps O(X) → S which preserve top, bottom and binary joins. We can use morphisms Σ X → Σ, which are automatically continuous with respect to the Σ-topologies, to describe these maps. We define our computable lower powerdomain as follows: The lower-powerdomain of A, written P l (A), is the regular subobject of Σ Σ A consisting of the top and bottom preserving morphisms Q satisfying the property, The upper powerdomain on X from [16] can be seen as Scott-continuous filters on the lattice of open sets O(X). By [3] these can be described as top and bottom preserving continuous functions O(X) → S which preserve finite meets. We again use the assembly Σ Σ A to describe these maps.

Definition 4.2
The upper-powerdomain of A, written P u (A), is the regular subobject of Σ Σ A consisting of the top and bottom preserving elements Q such that The probabilistic powerdomain on a space X as described in [8]  In our setting, we use the left computably enumerable (c.e.) real numbers in the interval [0, 1] described in [4]. A real number x is as such if the set {(p, q) ∈ N 2 | p q < x} is semi-decidable. We define the assembly [0, 1] of left c.e. real numbers realised by those r ∈ N such that r(pair p q) ↓ ⇔ p q < x. For this assembly we have a computable operation ⊕ : [0, 1] × [0, 1] → [0, 1] that sends (x, y) to (x + y)/2.
Hence there is only one completion of maps g : ω → [0, 1] constructed by taking defining g : ω → [0, 1] as g ( a) > p/q precisely when n (â(n) ∧ g( n) > p/q) = . So [0, 1] is complete, and hence by closure For the algebraically defined regular sub-objects, we can use the following trick. With P l (A) ⊂ Σ Σ A , we consider the equaliser of the two maps Q → λuv.(Q(u) ∨ Q(v)) and Q → λuv.Q(u∨v) from Σ Σ A to Σ Σ A ×Σ A . This assembly is complete since it is the equaliser on a complete assembly. P l (A) is the regular sub-object of this equaliser, defined by the bottom preservation condition. However for f : ω → Σ Σ A we have by continuity that f ( ∞)(λa.⊥) = ⊥ only if f ( a)(λa.⊥) = ⊥ for all a ∈ ω, and f ( ∞)(λa. ) = only if there is an a ∈ ω with f ( a)(λa. ) = ⊥. So top and bottom preservation is conserved in the ω-limits, hence P l (A) is complete. P u (A) and P p (A) go similarly, as both are top and bottom preserving regular sub-objects of algebraically defined equalisers on complete assemblies.
For the convex case we need to be more careful. For f : ω → Φ Σ A we can always find the unique completion f : ω → Φ Σ A argument-wise. So we only need to check

Interpreting the trees
We have given two descriptions for each of our considered paradigms of nondeterminism, one by establishing equivalences between trees and one using topological descriptions of power domains. In this section we will establish that we can computably interpret trees from the former description as elements in the latter. This will also allow us to computably test the equivalence classes on trees, such that we can lift a function f : The lower equivalence relation checks for which observations u ∈ Σ A there is a leaf a such that u ⊥ (a) = . We want to package this information into a single top and bottom preserving element of Σ Σ A ⊥ . We define ∃ A : T (A) → Σ Σ A ⊥ : ∃ A (t)(u) = ⇔ (u(⊥) = ) or (t has a leaf a such that u(a)) We give an explanation as to why this map is a computable morphism. Let f : 2 * → (A + 1) ⊥ be the morphism constructing the tree t. We use the obvious morphism γ : A ⊥ → (A + 1) ⊥ . Note that a ∈ A ⊥ is a leaf of t at α if and only if f (β) = γ(a) for any β extending α. This means there is a 1-1 correspondence between leaves of t and the set 'image(f ) ∩ image(γ)'. Let (−) : Σ A ⊥ → Σ (A+1) ⊥ be such thatů(η ⊥ (inr( * ))) = ⊥ andů(γ(a)) = u(a). To check the different leaves of a tree t, we use the enumeration e : N → 2 * of binary sequences to enumerate the domain of f . So we can find a representation of ∃ A using a morphism on the maps that construct the trees: f → λu : As an immediate consequence of the definition of ∃ A , we have that for any two trees t, r ∈ T A: ∃ A (t) = ∃ A (r) if and only if t ≡ l r, and ∃ A (t or r) = ∃ A (t) ∨ ∃ A (r). The following establishes that ∃ A maps into P l (A ⊥ ).

Lemma 5.1 For any t ∈ T
If u is the bottom element, then ∃ A (t)(u) = ⊥ ∨ (λn.⊥) = ⊥. So top and bottom are preserved.
Taking u, v ∈ Σ A ⊥ both not the top element, then u ∨ v is not the top element either. We have ∃ A (f )(u ∨ v) = if and only if there is a leaf a of t such that (u ∨ v)(a) = . So either a is a leaf such that u ⊥ (a) = or it is a leaf such that v ⊥ (a) = . Such a leaf exists if and only if ∃ A (t)(u) ∨ ∃ A (t)(v) = . 2 We can conclude that ∃ A can be seen as an injective map from T l (A) to P l (A ⊥ ), meaning it can be factored through an injective morphism ∃ A : T l (A) → P l (A ⊥ ).
For the upper case, we define ∀ A : T A → Σ Σ A ⊥ using the description of the upper-equivalence relation and adding top preservation:

or (t is finite and all leaves satisfy u)
In the category Asm, a binary tree is finite if and only if there is some maximal length to its branches. Our enumeration e : N → 2 * can be defined such that it enumerates the sequences in order of length, so we can use n 2 n −1≤m<2 n+1 −1 (ů • f • e(m)) to check whether for f ∈ (A + 1) 2 * ⊥ there is some n such for all binary sequences α of length n we haveů(f (α)) = . This is true for f precisely when the tree it constructs is finite and all its leaves satisfy u. Note that 2 n −1≤m<2 n+1 −1 uses a finite combination of ∧ operations, hence it is computable. So we can computably represent ∀ A using this construction, making it a computable morphism for any A.
We have by definition that ∀ A (t) = ∀ A (r) if and only if t ≡ u r, and ∀ A (t or r) = ∀ A (t) ∧ ∀ A (r). Mimicking the proof of 5.1 we also get the following, So ∀ A can also be seen as an injective map from T u (A) to P u (A).
For the convex case, we want to combine the upper and lower case. For this purpose we define the following map, : Φ × Φ → Φ as: Let φ : Σ → Φ be the map preserving top and bottom. Using these we simply define which intuitively means: if all leaves satisfy u ⊥ ∈ Σ A ⊥ then certainly there is a leaf that satisfies u ⊥ . One can see that ∃∀ A contains all the information of both ∃ A and ∀ A .
Since it uses a combination of ∃ A and ∀ A , we have that ∃∀ A (t) = ∃∀ A (r) if and only if t ≡ l r and t ≡ u r, which is precisely when t ≡ c r. Moreover, ∃∀ A (t or r) = ∃∀ A (t) ∃∀ A (r). This map again has its image within the appropriate powerdomain.

Lemma 5.3 The image of ∃∀
Proof. Top and bottom preservation properties are carried over from ∃ A and ∀ A . Let t ∈ T A and take u, v ∈ Σ A ⊥ two observations which are not λx. .
This means t is finite and all its leaves satisfy u. So for any leaf we get that it satisfies We can conclude that ∃∀ A can be seen as an injective map from T c (A) to P c (A ⊥ ).
Like in the probabilistic equivalence relation, we can also interpret trees as a series of 50-50 coin flips, and define the map Θ A : Here ℘ is the same as the one used in 3.6, except here we consider its output to be in [0, 1]. Of course, not all reals are left computably enumerable. So we check whether this map forms a well-defined computable morphism. Let t be a computable tree and f be the unique morphism constructing that tree. We define the n-th approximation of ℘(u, t) as: ℘ n (u, t) := α∈L t u ,length(α)≤n 2 −length(α) . Note that for α with length(α) = m ≤ n, there are precisely 2 n−m binary sequences of length n extending α. Since 2 n−m * 2 −n = 2 −m we have that with f constructing t, ℘ n (u, t) = 2 −n #{α ∈ 2 * |length(α) = n,ů(f (α))}. Hence ℘ n (u, t) is left computably enumerable. We get that ℘(u, t) = lim n→∞ ℘ n (u, t) is left computably enumerable, since given (p, q) ∈ N 2 we can compute ℘(u, t) > p q by looking for an n such that ℘ n (u, t) > p q . Hence Θ A is a well-defined and computable morphism. We have by definition that Θ A (t) = Θ A (r) ⇔ t ≡ c r. With the following lemma, we can conclude that Θ A can be seen as an injective map from T p (A) to P p (A ⊥ ).
Proof. Obviously Θ A (t) preserves top and bottom. For u, v ∈ Σ A , the real number Θ A (t)(u ⊥ )⊕Θ A (t)(v ⊥ ) is given by two summations, one over the leaves satisfying u ⊥ and one over the leaves satisfying v ⊥ . If a leaf is used in either of the summations, it satisfies u ⊥ ∨ v ⊥ = (u ∨ v) ⊥ , and if it is used in both summations it satisfies can be created by redistributing the elements of the summations used in Θ A (t)(u ⊥ ) ⊕ Θ A (t)(v ⊥ ). Hence they approach the same value. 2 Take f : A → T l (B) and the Kleislie lift f * : T A → T l (B) via T . Assume t ≡ l r, and u ∈ Σ B such that ∃ B (f * (t))(u) = . Then there is a leaf a of t such that there is a leaf of f (a) satisfying u. Hence ∃ A (t)(a → ∃ B (f (a))(u)) = , so since t ≡ l r and by injectivity we have ∃ A (r)(a → ∃ B (f (a))(u)) = meaning ∃ B (f * (r))(u) = . We can conclude that f * (t) ≡ l f * (r). So f * can be seen as a map T l A → T l (B) and similarly we have Kleisli lifts for the other non-deterministic paradgims.

Base case bijections
We have seen by construction that the maps ∃ A , ∀ A , ∃∀ A and Θ A can be seen as injective maps from the tree models T i (A) to the powerdomain models P i (A). We denote these specific injective maps as ∃ A , ∀ A , ∃∀ A and Θ A respectively. In this section we will establish that these maps are bijections in the case that A = N , and form isomorphisms in most of the base cases.
Note that for any a ∈ A. Since all elements of the computable powerdomains on A ⊥ are defined as top preserving maps on domain Σ A ⊥ , we can conclude that these elements are completely determined by their output on observations of the form u ⊥ with u ∈ Σ A . Lemma 6.1 The map ∃ N : T l (N ) → P l (N ⊥ ) is bijective and has an inverse.
Hence for any tree t in T N whose leaves are precisely those n such that Q((χ {n} ) ⊥ ) = , we have ∃ N (t) = Q. We can define the inverse with a morphism ∆ from Σ Σ N ⊥ to T N which for each n has a leaf at location α = 0 n 1 which is n if Q((χ {n} ) ⊥ ) = , else ⊥. This gives a computable inverse of ∃ N . 2 Proof. Let Q ∈ P u (N ⊥ ). By the characterisation of Σ Σ N in 2.7 we know that Q is determined by the values it outputs on inputs ( So with t ∈ T N some finite tree whose leaves are precisely the elements of V , we have ∀ N (t) = Q. Hence ∀ N is bijective.
Let τ : Σ → P u (N ⊥ ) be defined as τ (s)(u ⊥ ) := (u(0) ∧ u(1)) ∨ (u(0) ∧ s) for any u ∈ Σ N , and τ (s)(λx. ) = . Then τ ( )((χ V ) ⊥ ) = if and only if 0 ∈ V and τ (⊥)((χ V ) ⊥ ) = if and only if {0, 1} ⊂ V . We define a map ρ : T u (N ) → Σ that checks for t ∈ T N whether it is finite and it has a leaf labelled 1. This is well defined since it is invariant under the upper-equivalence. If we have a computable inverse κ : P u (N ⊥ ) → T u (N ), then we have a map ρ • κ • τ : Σ → Σ. This map sends to ⊥ since the inverse of τ ( ) is the equivalence class of finite trees with only leaves labelled 0 (no 1 leaves), and ⊥ is sent to since the trees in the equivalence classes mapped to τ (⊥) are finite trees with 1-leaves. So we have the switch map, which is impossible. We must conclude that the inverse is not computable. 2 In the convex case, things work out more neatly, because we have more information. Let Q = ∃∀ N (t) and ter ∈ Σ N be the test (λx. ), then Q(ter ⊥ ) = if and only if t is finite and has no ⊥-leaves. For each m ∈ N we have the mutually exclusive tests; I ≤ Φ Q(( n≥m χ {n} ) ⊥ ) checking whether t has a leaf m ∈ N with m ≥ n, and Q((χ V<m ) ⊥ ) = with V <m := {n|n < m} checking whether t is finite and all its leaves are natural numbers below m. If Q(ter ⊥ ) = , meaning t is finite, one of these two tests must terminate, hence making a decidable test of whether all leaves are below m. We also construct a map sm : Φ Σ N → N ⊥ that gives ⊥ if Q(ter ⊥ ) = , and otherwise finds the first n ∈ N for which the now decidable check . So if t is finite without ⊥-leaves, sm(Q) will give the smallest leaf of t. We create a morphism Λ : P p (N ⊥ ) → T c N as follows, where we define what leaf or node Λ(Q) has at certain locations if no leaves preceded that location:  If neither it will be ⊥.
From this construction we can see that Λ(Q) gives a tree whose leaves are precisely the leaves of t, and is infinite or has a leaf ⊥ if t is infinite. With this map we can retrieve from Q some tree Λ(Q) such that Λ(Q) ≡ c t. The following lemma establishes that all Q ∈ P c (N ) originate from T N via ∃∀ N . Lemma 6.3 The morphism ∃∀ N is bijective and hence Λ forms an inverse.
Proof. Let Q ∈ P c (N ⊥ ) and for convenience of notation let Q ∈ Φ Σ N be defined such that Q (u) := Q(u ⊥ ). We do a case distinction by value of Q (ter). Since for any u ∈ Σ N we have u ≤ Σ N ter we get Q (u) ≤ Σ Q (ter). So a Q with Q (ter) = ⊥ will always give ⊥ except for the top element. Hence Q is reached by trees whose only leaves are ⊥. Now for the other cases: If Q (ter) = I, we need a tree that is somewhere terminating but not everywhere. We have that for u ∈ Σ N , Q (u) ≤ Σ Q (ter) = I. So Q only outputs I or ⊥.
So Q is now a lattice with Q (u∨v) = Q (u)∨Q (v), and so is Q. Taking m : Φ → Σ sending ⊥ → ⊥ and I → , we get that m • Q is now in the lower powerdomain P l (N ). Take t := ∆(m • Q) the infinite tree constructed in 6.1, then ∃∀ N (t) = Q.
If Q (ter) = , we know by continuity that there is a finite set V ⊂ N such that Looking at all such finite sets, we know we can find a smallest one (by property (ii) of the powerdomain). Let V be as such, we have Q (u) = ⇔ χ V ≤ Σ N u. Now if Q (u) = ⊥, then there are elements x ∈ V such that u(x) = ⊥. Take W ⊂ V all those elements. So χ W ∧ u = λx.⊥ and We can conclude that all values for Q and Q are determined by this one finite set V . So the finite tree whose leaves are precisely those from V is mapped into Q by ∃∀ N .2 For the lower and convex case, the inverses are established by constructing a specific tree in T N . So the inverses factor through T N and don't need the equivalence classes to be well defined. In the probabilistic case however, we will depend heavily on the specific coding of elements in the powerdomain. We use the convenient decidable test on specific codes, ab ↓ n that checks whether the a-th Turing machine applied to b terminates in n steps. In constructing a tree from some code of a powerdomain element, you can be careful by only checking a finite amount of things, so your tests are always decidable and never get you into a ⊥-loop.
Lemma 6.4 The morphism Θ N is bijective and has an inverse.
is the sum of all Q((χ {n} ) ⊥ ) over n ∈ V . Since any u ∈ Σ N is approached by these finite χ V (see 2.6) we have that Q is completely determined by the values Q((χ {n} ) ⊥ ). So we need to construct a computable tree such that the probability of ending up at a leaf n is a n := Q((χ {n} ) ⊥ ) ∈ [0, 1].
Let r Q ∈ ||Q|| Pp(N ⊥ ) , and x e a realiser of the map n → (χ {n} ) ⊥ . For each m, we give a lower approximation of the probabilities by checking for all 0 ≤ n < m, 0 ≤ b ≤ m and 0 < a < 2 b whether r Q (x e n)(pair a 2 b ) ↓ m . This term will halt for some m precisely if a n > a 2 b . This gives us a computable approximation of the probabilities given by a n . Note that for higher m we always gain information, never lose it. Now we generate the tree by using the m-th approximation at height m in the tree and outputting leaves whenever one has sufficient enough information to do so. E.g. when at m we know that a n > a 2 b we can make sure that for a2 m−b different binary sequences there is a leaf n at some subsequence. Using such a procedure, we can construct a tree approximating the probabilities level by level. This will give us an inverse morphism Θ −1 N :

Representation theorems
In the upper and lower case, our powerdomains are subobjects of Σ Σ A , which has the structure of a continuation type. The functor Σ Σ (−) forms a monad, with the natural morphisms defined as η Σ A (a) := (u → u(a)) and µ Σ A (F ) := (u → F (Q → Q(u))). The morphism η Σ A (a) preserves both ∨ and ∧ for any a, and if F preserves ∨ and/or ∧ then so does µ Σ A (F ). Hence P l (−) and P u (−) form sub-monads of this monad. We would like a similar sub-monad of a continuation monad in the convex and probabilistic case. For the first one, we define the following structure as in [3], using the assembly Φ := Σ ⊥ with renamed elements {⊥, I, }.
Definition 7.1 The continuation convex powerdomain of A, denoted C c (A), is the regular subobject of Φ Φ A of top and bottom preserving maps Q satisfying: Proposition 7.2 For each A there is an isomorphism between P c (A) and C c (A).