1 Introduction

Computational effects can be modelled using monads, and in some functional programming languages (notably Haskell) they are commonly used as a program structuring device. In the presence of dependent types one can both write and reason about monadic programs. From a type theorist’s point of view, even a “pure” functional language like Haskell is not really pure as it has built-in effects, one of which is partiality: a function does not necessarily terminate. It is thus natural to look for a partiality monad which makes it possible to model partial computations and to reason about possibly non-terminating programs.

Capretta modeled partial computations using a coinductive construction that we call the delay monad [6]. We use the notation \(\mathrm D\! \left( A\right) \) for Capretta’s type of delayed computations over a type A. \(\mathrm D\! \left( A\right) \) is coinductively generated by \(\mathsf {now}: A \rightarrow \mathrm D\! \left( A\right) \) and \(\mathsf {later}: \mathrm D\! \left( A\right) \rightarrow \mathrm D\! \left( A\right) \). Examples of elements of \(\mathrm D\! \left( A\right) \) include \(\mathsf {now}(a)\) and \(\mathsf {later}(\mathsf {later}(\mathsf {now}(a)))\), as well as the infinitely delayed value \(\bot \), defined by the guarded equation \(\bot = \mathsf {later}(\bot )\). We can model recursive programs as Kleisli arrows \(A \rightarrow \mathrm D\! \left( B\right) \), and we can construct fixpoints of (\(\omega \)-continuous) functions of type \((A \rightarrow \mathrm D\! \left( B\right) ) \rightarrow (A \rightarrow \mathrm D\! \left( B\right) )\), see Benton et al. [5].

Unfortunately, Capretta’s delay monad is sometimes too intensional. It is often appropriate to treat two computations as equal if they terminate with the same value, but the delay monad allows us to count the number of “steps” (\(\mathsf {later}\) constructors) used by a computation.

Capretta addressed this problem by defining a relation that we call weak bisimilarity, \(\sim _{\mathrm D}\), and that relates expressions that only differ by a finite number of \(\mathsf {later}\) constructors [6]. Capretta proved that the delay monad combined with weak bisimilarity is a monad in the category of setoids.

A setoid is a pair consisting of a type and an equivalence relation on that type. Setoids are sometimes used to approximate quotient types in type theories that lack support for quotients. However, a major difference between setoids and quotient types is that setoids do not provide a mechanism for information hiding. Using the setoid approach basically boils down to introducing a new relation together with the convention that all constructions have to respect this relation. A problem with this approach is that it can lead to something which has informally become known as setoid hell, in which one is forced to prove that a number of constructions—even some that do not depend on implementation details by, say, pattern matching on the \(\mathsf {now}\) and \(\mathsf {later}\) constructors—preserve setoid relations. This kind of problem does not afflict quotient types.

In a type theory with quotient types [14], one can consider using the quotient \({\mathrm D\! \left( A\right) }/{\sim _{\mathrm D}}\) as the type of partial computations of type A. This idea was discussed in a talk by Uustalu [7], reporting on joint work with Capretta and the first-named author of the current paper. However, the idea does not seem to work as intended. It is an open problem—and believed to be impossible—to show that this construction actually constitutes a monad (in “usual” forms of type theory).

With an additional assumption, Chapman et al. have managed to show that the partiality operator \({\mathrm D\! \left( -\right) }/{\sim _{\mathrm D}}\) is a monad [8]. This additional assumption is known as countable choice. To express what this is, first note that the propositional truncation, written \({||}{-}{||}\) and sometimes called “squashing”, is an operation that turns a type into a proposition (a type with at most one element). We can see \({||}{A}{||}\) as the quotient of A by the total relation. Countable choice says that \(\varPi \) and \({||}{-}{||}\) commute if the domain is the natural numbers, in the sense that there is a function from \(\varPi _{n:\mathbb {N}} \, {||}{P(n)}{||}\) to \({||}{\varPi _{n:\mathbb {N}} \, P(n)}{||}\). Even though this principle holds in some models, its status in type theory is unclear: the principle is believed to be independent of several variants of type theory. Recently Coquand et al. have shown that it cannot be derived in a theory with propositional truncation and a single univalent universe [10], speculating that the result might extend to a theory with a hierarchy of universes. Furthermore Richman argues that countable choice should be avoided in constructive reasoning [18]. The main purpose of the present paper is to define a partiality monad without making use of this principle.

The situation with the quotiented delay monad is similar to that of one variant of the real numbers in constructive mathematics. If the Cauchy reals are defined as a quotient, then it is impossible to prove a specific form of the statement that every Cauchy sequence of Cauchy reals has a limit using \(\mathsf {IZF}_\mathrm {Ref}\), a constructive set theory without countable choice [17]. It is suspected that corresponding statements are also impossible to prove in several variants of type theory. An alternative solution was put forward in the context of homotopy type theory [20]. In that approach, the reals are constructed inductively simultaneously with a notion of closeness, and the quotienting is done directly in the definition using a higher inductive-inductive type (HIIT).

In 2015, Andrej Bauer and the first-named author of the current paper suggested to use a similar approach to define a partiality monad without using countable choice, an idea which was mentioned by Chapman et al. [8]. Here, we show that this is indeed possible.

We do not make use of the full power of HIITs, but restrict ourselves to set-truncated HIITs. We call such types quotient inductive-inductive types, QIITs, following Altenkirch and Kaposi [1]. Some of the theory of QIITs is developed in the forthcoming PhD thesis of Dijkstra [12], see also Altenkirch et al. [2]. Although type theory extended with QIITs is still experimental and currently lacks a solid foundation, QIITs are a significantly simpler concept than full-blown HIITs. It is conjectured that QIITs exist in some computational models of type theory.

The type theory that we work in can be described as a fragment of the theory considered in the standard textbook on homotopy type theory [20] (henceforth referred to as the HoTT book), and is quite close to the theory considered by Chapman et al. [8]. Details are given in Sect. 2. The construction of our partiality monad is given in Sect. 3, together with its elimination principle and some properties. Furthermore we show that it gives us free \(\omega \)-cpos in a sense that we will make precise. In Sect. 4 we show that, assuming countable choice, our partiality monad is equivalent to (in bijective correspondence to) the one of Chapman et al. [8]. We outline some applications of the partiality monad in Sect. 5, and conclude with a short discussion in Sect. 6.

Agda Formalisation. The paper is accompanied by a formal development [3] in Agda.

At the time of writing, Agda does not directly support QIITs. We have chosen to represent them by postulating their elimination principles together with the equalities they are supposed to satisfy. In some cases (but not for the partiality monad) we have also made use of Agda’s experimental rewriting feature [9] to turn postulated equalities into judgmental computation rules.

Note that there are differences between the Agda code and the presentation in the text. For one, the formalisation discusses various additional topics that have been omitted in the paper for reasons of space, and is more rigorous. Furthermore, the paper defines the partiality monad’s elimination principle as a universal property. In the formalisation the elimination principle is given as an induction principle, but we also prove that this principle is interderivable with the universal property. Finally there are a number of small differences between the formalisation and the text, and some results in the paper have not been formalised at all, most notably the results about the reals in Sect. 5.2.

2 Background: Type Theory with Quotient Inductive-Inductive Types

We work in intensional type theory of Martin-Löf style with all the usual components (e.g. \(\varPi \), \(\varSigma \), inductive types), including the identity type (we use the notation \(x = y\)). We assume that equality of functions is extensional, and that (strong) bisimilarity implies equality for coinductive types.

Chapman et al. [8] assume the axiom of uniqueness of identity proofs, UIP, for all small types (types in the lowest universe). UIP holds for a type A if, for any elements x, y : A, if we have equalities p, \(q : x = y\), then we have \(p = q\). Instead of postulating an axiom, we prefer to work in a more general setting and restrict ourselves to types with the corresponding property. This approach is compatible with homotopy type theory. In the language of homotopy type theory, we work with sets or 0-truncated types; a type is a set if and only if it satisfies UIP. When we write \(A : \mathsf {Set}\), we mean that A is a type (in some universe) with the property of being a set; and when we write \(B : A \rightarrow \mathsf {Set}\), we mean that B is a family of types such that each B(a) is a set.

Similarly to \(A : \mathsf {Set}\), we write \(P : \mathsf {Prop}\) for a type P with the property that it is a proposition, i.e. a \((-1)\)-truncated type, i.e. a type with the property that any two of its elements are equal. A proposition is also a set. The type of all propositions in a certain universe is closed under all operations that are relevant to us, and the same applies to sets.

In addition to UIP, Chapman et al. [8] assume propositional extensionality—that logically equivalent propositions are equal—for all small propositions. This property is equivalent to the univalence axiom [20], restricted to (small) propositions. Just like Chapman et al., we only require propositional extensionality (not full univalence) for our development, with the exception that univalence is used to show that certain precategories (in the sense of the HoTT book [20]) are categories. For an example of how propositional extensionality is used, see Lemma 7.

Chapman et al. [8] also assume the existence of quotient types in the style of Hofmann [14]. Given a set A and a propositional relation \(\sim \) on it, the (set-) quotient \({A}/{\sim }\) can in homotopy type theory be constructed as a higher inductive type with three constructors [20]:

The last constructor \(\mathsf {irr}\) ensures that any two parallel equalities are equal, that is, that \({A}/{\sim }\) is set-truncated. We call a higher inductive type with such a set-truncation constructor a quotient inductive type (QIT).

As noted above, Chapman et al. [8] use countable choice, which we want to avoid. Instead we make use of quotient inductive-inductive types (QIITs) [2, 12]. From the point of view of homotopy type theory, these are set-truncated higher inductive-inductive types (HIITs); some other examples of HIITs can be found in the HoTT book [20, Chap. 11]. While it seems plausible that QIITs exist in some computational models of type theory, this has yet to be determined.

3 The Partiality Monad

As indicated in the introduction we define the partiality monad \((-)_{\bot }\) as a QIIT, defining the type \(A_{\bot }\) simultaneously with an ordering relation \(\sqsubseteq \) on \(A_{\bot }\). We will first describe the constructors and the elimination principle of this definition, and then show that \(A_{\bot }\) is the underlying type of the free \(\omega \)-cpo (see Definition 4) on A, thus proving that \((-)_{\bot }\) is a monad. In the final part of this section we will give a characterisation of the ordering relation; this is perhaps not as trivial as one might expect, given the relation’s definition.

Note that our construction of \(A_{\bot }\) can be seen as a further example of a free algebraic structure defined in type theory. It was discussed in the HoTT book [20, Chap. 6.11] that free groups can be defined as (in our terminology) quotient inductive types, while it is well-known that even simpler examples can be defined as ordinary inductive types.

3.1 The Definition and Its Elimination Principles

Let A be a set. We define the set \(A_{\bot }\) simultaneously with a binary propositional relation on \(A_{\bot }\), written \(\sqsubseteq \). The set \(A_{\bot }\) is generated by the following four constructors, plus a set-truncation constructor:

$$\begin{aligned} \begin{alignedat}{6}&\eta&\;&:&\;&A \rightarrow A_{\bot }&\qquad \qquad&\bigsqcup&\;&:&\;&\left( \varSigma _{s : \mathbb {N}\rightarrow A_{\bot }} \, \varPi _{n:\mathbb {N}} \, s_n \sqsubseteq s_{n+1}\right) \rightarrow A_{\bot } \\&\bot&\;&:&\;&A_{\bot }&\qquad \qquad&\alpha&\;&:&\;&\varPi _{x,y : A_{\bot }} \, x \sqsubseteq y \rightarrow y \sqsubseteq x \rightarrow x = y \end{alignedat} \end{aligned}$$

The constructor \(\eta \) tells us that any element of A can be viewed as an element of \(A_{\bot }\), and \(\bot \) represents a non-terminating computation. The constructor \(\bigsqcup \) is intended to form least upper bounds of increasing sequences, and \(\alpha \) ensures that the ordering relation \(\sqsubseteq \) is antisymmetric.

The relation \(\sqsubseteq \) is a type family that is indexed twice by \(A_{\bot }\). It is generated by six constructors. One of these constructors says that, for any \(x, y : A_{\bot }\), the type \(x \sqsubseteq y\) is a proposition (\(\varPi _{p,q : x \sqsubseteq y} \, p = q\)). Because any two proofs of \(x \sqsubseteq y\) are equal, we do not name the constructors of the ordering relation. The remaining constructors are given as inference rules, where each rule is implicitly \(\varPi \)-quantified over its unbound variables (the same comment applies to other definitions below):

figure a

The rules state that \(\sqsubseteq \) is reflexive and transitive, that \(\bot \) is at least as small as any other element of \(A_{\bot }\), and that \(\bigsqcup \) constructs least upper bounds.

Now we will give the elimination principle of \((-)_{\bot }\) and \(\sqsubseteq \). This principle can be stated in different ways. One way would be to state it as an induction principle, along the following lines: Given a family \(P : A_{\bot } \rightarrow \mathsf {Set}\) and [...something for \(\sqsubseteq \)...], and given elements of \(P(\bot )\), \(\varPi _{a : A} \, P(\eta (a))\), [...and so on...], we can conclude that \(\varPi _{x : A_{\bot }} \, P(x)\) and [...]. We take this approach in our formalisation; for another example, see the presentation of the Cauchy reals in the HoTT book [20, Chap. 11.3.2]. However, because the two types are defined simultaneously and involve constructors targeting the equality type, the induction principle may look somewhat involved and perhaps even ad-hoc, and it may not be obvious that it is the “correct” one.

Instead, we present a universal property. Dijkstra [12] and Altenkirch et al. [2] have worked out a general form and rules for a large class of quotient inductive-inductive types. In their setting, any specification of a QIIT gives rise to a category of algebras, following methods that have been used for W-types [4] and certain higher inductive types [19], and if this category has a (homotopy-) initial object, then this object is taken as the definition of the QIIT. We use the following algebras:

Definition 1

(partiality algebras). A partiality algebra over the set A consists of a set X; a propositional binary relation on X, \(\sqsubseteq _X\); an element \(\bot _X : X\), a family \(\eta _X : A \rightarrow X\), and a family \(\bigsqcup _X : (\varSigma _{s : \mathbb {N}\rightarrow X} \, \varPi _{n : \mathbb {N}} \, s_n \sqsubseteq _X s_{n+1}) \rightarrow X\); and the following laws:

$$\begin{aligned} \begin{alignedat}{6}&x \sqsubseteq _X x&\qquad&x \sqsubseteq _X y \rightarrow y \sqsubseteq _X z \rightarrow x \sqsubseteq _X z \\&\bot _X \sqsubseteq _X x&\qquad&x \sqsubseteq _X y \rightarrow y \sqsubseteq _X x \rightarrow x = y \\&\varPi _{n : \mathbb {N}} \, s_n \sqsubseteq _X \bigsqcup _X(s,p)&\qquad&\left( \varPi _{n : \mathbb {N}} \, s_n \sqsubseteq _X x\right) \rightarrow \bigsqcup _X(s,p) \sqsubseteq _X x \end{alignedat} \end{aligned}$$

The type X and the type family \(\sqsubseteq _X\) are allowed to target universes distinct from the one that A lives in.

For two partiality algebras over the same set A, \((X, \sqsubseteq _X, \bot _X, \eta _X, \bigsqcup _X)\) and \((Z, \sqsubseteq _Z, \bot _Z, \eta _Z, \bigsqcup _Z)\), a morphism of partiality algebras from the former to the latter consists of a function \({f : X \rightarrow Z}\) satisfying the following laws: First, f has to respect the ordering relation, \(f^{\sqsubseteq } : x \sqsubseteq _X y \rightarrow f(x) \sqsubseteq _Z f(y)\). Second, f has to preserve some of the constructors, \(f(\bot _X) = \bot _Z\), \(f \circ \eta _X = \eta _Z\), and \(f(\bigsqcup _X(s,p)) = \bigsqcup _Z(f \circ s, f^{\sqsubseteq } \circ p)\).

Let us denote this structure of objects and morphisms by \(\mathsf {Part}_A\).

The structure \(\mathsf {Part}_A\) is a category, in which the identity morphism is the identity function, and composition of morphisms is composition of functions.

We can now make the elimination principle precise. Note that the tuple \((A_{\bot }, \sqsubseteq , \bot , \eta , \bigsqcup )\) is a partiality algebra. As the elimination principle of \(A_{\bot }\) and \(\sqsubseteq \) we take the statement that there is a unique (up to equality) morphism from this partiality algebra to any other partiality algebra over A. In the terminology of the HoTT book [20], the statement that there is a morphism is basically the recursion principle of \((-)_{\bot }\) and \(\sqsubseteq \), while uniqueness gives us the power of the induction principle (with propositional computation rules). Note that allowing the type X and the type family \(\sqsubseteq _X\) to target arbitrary universes enables us to make use of large elimination.

We do not lose anything by using a universal property instead of an induction principle, at least for the induction principle referred to in the following theorem. The theorem is similar to results due to Dijkstra [12] and Altenkirch et al. [2]. It is stated without proof here, but a full proof of the fact can be found in our Agda development.

Theorem 2

The elimination principle of \(A_{\bot }\) and \(\sqsubseteq \) can be stated as an induction principle. This induction principle, which comes with propositional rather than definitional computation rules, is interderivable with the universal property given above.

Note that we could have defined \(A_{\bot }\) and \(\sqsubseteq \) differently. For instance, we could have omitted the set-truncation constructor from the definition of \(A_{\bot }\), and then proved that the type is a set, following the approach taken for the Cauchy reals in the HoTT book [20]. However, if we had done this, then our definitions would have been less close to the general framework mentioned above [2, 12].

As a simple demonstration of the universal property we construct an induction principle for \(A_{\bot }\) that can be used when eliminating into a proposition. Following the terminology of the HoTT book [20, Chap. 11.3.2], we call it partiality induction:

Lemma 3

Let P be a family of propositions on \(A_{\bot }\) such that both \(P(\bot )\) and \({\varPi _{a:A} \, P(\eta (a))}\) hold. Assume further that, for any increasing sequence s :  \(\mathbb {N}\rightarrow A_{\bot }\) (with corresponding proof p), \(\varPi _{n : \mathbb {N}} \, P(s_n)\) implies \(P(\bigsqcup (s,p))\). Then we can conclude \(\varPi _{x : A_{\bot }} \, P(x)\).

Proof

The proof uses a standard method. We define a partiality algebra where the set is ; the binary relation is \(\sqsubseteq \), ignoring the second projections of the values in Z; and the rest of the algebra is constructed using the assumptions. The universal property gives us a morphism m from the initial partiality algebra to this one, and in particular a function of type \(A_{\bot } \rightarrow Z\). We are done if we can show that this function, composed with the first projection, is the identity on \(A_{\bot }\). Note that the first projection can be turned into a partiality algebra morphism \(\mathsf {fst}\). Thus, by uniqueness, the composition of \(\mathsf {fst}\) and m has to be the unique morphism from the initial partiality algebra to itself, and the function component of this morphism is the identity.    \(\square \)

3.2 \(\omega \)-Complete Partial Orders

Another way of characterising our quotient inductive-inductive partiality monad is to say that \(A_{\bot }\) is the free (pointed) \(\omega \) -cpo over A:

Definition 4

Let us denote the category \(\mathsf {Part}_{\mathbf {0}}\), where \(\mathbf {0}\) is the empty type, by \(\mathsf {\omega }\)-\(\mathsf {CPO}\). An \(\omega \)-cpo is an object of this category.

Let us quickly check that this definition makes sense. A partiality algebra on \(\mathbf {0}\) is a set X with a binary propositional relation \(\sqsubseteq _X\) that is a partial order. There is a least element \(\bot _X\) and any increasing sequence has a least upper bound. There is also a function of type \(\mathbf {0}\rightarrow X\), which we omit below as it carries no information.

We can now relate the category of sets [20, Example 9.1.7], written \(\mathsf {SET}\), to the category \(\mathsf {\omega }\)-\(\mathsf {CPO}\). For any \(\omega \)-cpo we can take the underlying set, and it is easy to see that this yields a functor, in the sense of the HoTT book [20, Definition 9.2.1], \(\mathsf {U} :\) \(\mathsf {\omega }\)-\(\mathsf {CPO}\) \(\rightarrow \mathsf {SET}\).

We also have a functor \(\mathsf {F} : \mathsf {SET} \rightarrow \) \(\mathsf {\omega }\)-\(\mathsf {CPO}\), constructed as follows: The functor maps a set A to the \(\omega \)-cpo \((A_{\bot }, \sqsubseteq , \bot , \bigsqcup )\). For the morphism part, assume that we have a function \(f : A \rightarrow B\). Then \((B_{\bot }, \sqsubseteq , \bot , \eta \circ f, \bigsqcup )\) is an A-partiality algebra, and hence there is a morphism to this algebra from the initial A-partiality algebra \((A_{\bot }, \sqsubseteq , \bot , \eta , \bigsqcup )\). By removing the components \(\eta \circ f : A \rightarrow B_{\bot }\) and \(\eta : A \rightarrow A_{\bot }\) we get a morphism between \(\omega \)-cpos.

The function \(\eta \) lifts to a natural transformation from the identity functor to \(\mathsf {U} \circ \mathsf {F}\). In order to construct a natural transformation from \(\mathsf {F} \circ \mathsf {U}\) to the identity functor, assume that we are given some \(\omega \)-cpo X. We can construct an \(\omega \)-cpo morphism from \(\mathsf {F}(\mathsf {U}(X))\) to X by noticing that \((\mathsf {U}(X), \sqsubseteq _X, \bot _X, id , \bigsqcup _X)\) is a partiality algebra on \(\mathsf {U}(X)\), and thanks to initiality we get a morphism m from \(\mathsf {F}(\mathsf {U}(X))\) to X satisfying \(m \circ \eta = id \). After proving some equalities we end up with the following result, where the definition of “adjoint” is taken from the HoTT book [20, Definition 9.3.1]:

Theorem 5

For a given set A, the functor \(\mathsf F\) is a left adjoint to the forgetful functor \(\mathsf U\). This means that \(\mathsf F(A)\) can be seen as the free \(\omega \)-cpo over A.    \(\square \)

Thus we get a justification for calling the concept that we are discussing the partiality monad:

Corollary 6

The composition \(\mathsf U \circ \mathsf F : \mathsf {SET} \rightarrow \mathsf {SET}\), which maps objects A to \(A_{\bot }\), is a monad.    \(\square \)

Note that one can also construct a monad structure on \((-)_{\bot }\) directly. Let us fix the set A. The unit is given by \(\eta \). For the multiplication \(\mu : (A_{\bot })_{\bot } \rightarrow A_{\bot }\), note that \(A_{\bot }\) can be given the structure of a partiality algebra over \(A_{\bot }\) in a trivial way: the underlying set is \(A_{\bot }\), the function \(\eta _{A_{\bot }} : A_{\bot } \rightarrow A_{\bot }\) is the identity, \(\sqsubseteq _{A_{\bot }}\) is \(\sqsubseteq \), and so on. This gives us the function \(\mu \) as the unique morphism from the initial partiality algebra to this one. Proving the monad laws is straightforward.

3.3 A Characterisation of the Relation \(\sqsubseteq \)

To further analyse the QIIT construction, we show how the relation \(\sqsubseteq \) on the set \(A_{\bot }\) behaves.Footnote 1 These results are useful when working with the partiality monad, and will play an important role in the next section of the paper. The arguments are only sketched here, details are given in the formalisation. We use the propositional truncation \({||}{-}{||}\) (also known as “squashing”), which turns a type into a proposition. It can be implemented by quotienting with the trivial relation.

We know that \(\bot \sqsubseteq y\) is (by definition) satisfied for any \(y : A_{\bot }\), and for the least upper bound we have that \(\bigsqcup (s,q) \sqsubseteq y\) is equivalent to \(\varPi _{n:\mathbb {N}} \, s_n \sqsubseteq y\). The following lemma provides a characterisation of \(\eta (a) \sqsubseteq y\), for any a : A:

Lemma 7

The binary relation \(\sqsubseteq \) on \(A_{\bot }\) has the following properties:

$$\begin{aligned} \begin{alignedat}{3} \eta (a)&\,\sqsubseteq \bot&\quad&\leftrightarrow&\quad&\mathsf {0} \\ \eta (a)&\,\sqsubseteq \eta (b)&\quad&\leftrightarrow&\quad&a = b \\ \eta (a)&\,\sqsubseteq \bigsqcup (s,q)&\quad&\leftrightarrow&\quad&{||}{\varSigma _{n:\mathbb {N}} \, \eta (a) \sqsubseteq s_n}{||} \end{alignedat} \end{aligned}$$

We will give the proof of this lemma later and make a remark first. Constructors in “HIT-like” definitions, e.g. QIITs, may in general be neither injective nor disjoint. For instance, \(\bigsqcup (\lambda n . \bot ,q)=\bot \). However, we have the following lemma:

Corollary 8

For any a : A and \(y : A_{\bot }\), we have that \(\eta (a) \sqsubseteq y\) implies that \(\eta (a) = y\). In particular, \(\eta \) is injective: if \(\eta (a) = \eta (b)\), then \(a = b\). Moreover, we have \(\eta (a) \not = \bot \).

Proof

(of Corollary 8 ). The last two claims are simple consequences of the lemma and reflexivity. For the first claim, let us fix a : A and apply Lemma 3 with . The only non-immediate step is the case for \(\bigsqcup (s,q)\), where we can assume \(\varPi _{n : \mathbb {N}} \, P(s_n)\). From \(\eta (a) \sqsubseteq \bigsqcup (s,q)\) and Lemma 7 we get \({||}{\varSigma _{n:\mathbb {N}} \, \eta (a) \sqsubseteq s_n}{||}\). We are proving a proposition, so we can assume that we have \(n:\mathbb {N}\) such that \(\eta (a) \sqsubseteq s_n\). This implies that, for all \(m \ge n\), \(\eta (a) \sqsubseteq s_m\) and hence, by the “inductive hypothesis”, \(\eta (a) = s_m\). Thus \(\eta (a)\) is an upper bound of s, so we get \(\bigsqcup (s,q) \sqsubseteq \eta (a)\), which by antisymmetry implies \(\bigsqcup (s,q) = \eta (a)\).    \(\square \)

The proof of the lemma is more technical. The approach is similar to that used to prove some results about the real numbers defined as a HIIT in the HoTT book [20, Theorems 11.3.16 and 11.3.32]. We only give a sketch here, the complete proof can be found in our Agda formalisation.

Proof

(of Lemma 7 ). For every a : A we construct a relation in \(A_{\bot } \rightarrow \mathsf {Prop}\) by applying the elimination principle of \(A_{\bot }\) and \(\sqsubseteq \), treating \(\mathsf {Prop}\) as a partiality algebra over A in the following way:

Propositional extensionality is used to prove that \(\mathsf {Prop}\) is a set (this is a variant of an instance of Theorem 7.1.11 in the HoTT book [20]), and to prove the antisymmetry law.

Using Lemma 3 one can then show that the defined relation is pointwise equal to \(\eta (a) \sqsubseteq -\), and it is easy to see that the relation has the properties claimed in the statement of Lemma 7.    \(\square \)

Using the results above one can prove that the order is flat, in the sense that if x and y are distinct from \(\bot \) and \(x \not = y\), then \(x \not \sqsubseteq y\) (see the formalisation).

4 Relation to the Coinductive Construction

In this section we compare our QIIT to Capretta’s coinductive delay monad [6], quotiented by weak bisimilarity [8]. Let us start by giving Capretta’s construction, as already outlined in the introduction. \(\mathcal {U}\) stands for a universe of types.

Definition 9

(delay monad and weak bisimilarity). For a set A the delay monad \(\mathrm D\! \left( A\right) \) is the coinductive type generated by \(\mathsf {now}: A \rightarrow \mathrm D\! \left( A\right) \) and \(\mathsf {later}: \mathrm D\! \left( A\right) \rightarrow \mathrm D\! \left( A\right) \). The “terminates with” relation \(\downarrow _{\mathrm D}\ : \mathrm D\! \left( A\right) \rightarrow A \rightarrow \mathcal {U}\) is the indexed inductive type generated by two constructors of type \(\eta (a) \downarrow _{\mathrm D} a\) and \(p \downarrow _{\mathrm D}~a \rightarrow \mathsf {later}(p) \downarrow _{\mathrm D} a\). Furthermore, x and \(y : \mathrm D\! \left( A\right) \) are said to be weakly bisimilar, written \(x \sim _{\mathrm D} y\), if \(\varPi _{a:A} \, x \downarrow _{\mathrm D} a \leftrightarrow y \downarrow _{\mathrm D} a\) holds.

It is easy to give \(\mathrm D\! \left( A\right) \) the structure of a monad. Note that \(x \downarrow _{\mathrm D} a\) can alternatively be defined to be \(\varSigma _{n : \mathbb {N}} \, x = \mathsf {later}^n(\mathsf {now}(a))\). The types \(x \downarrow _{\mathrm D} a\) and \(x \sim _{\mathrm D} y\) are propositional, and \(\sim _{\mathrm D}\) is an equivalence relation on \(\mathrm D\! \left( A\right) \).

The goal of this section is to show that, in the presence of countable choice, the partiality monad \(A_{\bot }\) is equivalent to \({\mathrm D\! \left( A\right) }/{\sim _{\mathrm D}}\). (We use the notion of equivalence from the HoTT book [20], which for sets is equivalent to bijective correspondence.) To understand the structure of the proof, let us observe that \({\mathrm D\! \left( A\right) }/{\sim _{\mathrm D}}\) is constructed as a “coinductive type that is quotiented afterwards”, while \(A_{\bot }\) is an “inductive type that is quotiented at the time of construction”. To build a connection between these, it seems rather intuitive to consider an intermediate construction, either a “coinductive type that is quotiented at the time of construction” or an “inductive type that is quotiented afterwards”. The theory of “higher coinductive types” has, as far as we know, not been explored much yet, so we go with the second option. We do not even need an inductive construction: it is well-known that coinductive structures can be represented using finite approximations, and here, it is enough to consider monotone functions. Thus, first we will show that \(\mathrm D\! \left( A\right) \) is equivalent to a type of monotone sequences, carefully formulated, and that the equivalence lifts to the quotients. Then we will prove that, assuming countable choice, the quotiented monotone sequences are equivalent to \(A_{\bot }\).

4.1 The Delay Monad and Monotone Sequences

For a set A we say that a function \(g : \mathbb {N}\rightarrow A + \mathbf {1}\) is a monotone sequence if it satisfies the propositional property

The set of monotone sequences, \(\varSigma _{g : \mathbb {N}\rightarrow A + \mathbf {1}} \, \mathsf {ismon}(g)\), is denoted by \(\mathsf {Seq}_A\). Below the notation \(-_n\) will be used not only for functions, but also for monotone sequences; \((g,p)_n\) means \(g_n\).

As Chapman et al. [8] observe, one can construct a sequence of type \(\mathbb {N}\rightarrow A + \mathbf {1}\) from an element of \(\mathrm D\! \left( A\right) \). If their construction is tweaked a little, then the resulting sequences are monotone, and the map is an equivalence:

Lemma 10

The types \(\mathsf {Seq}_A\) and \(\mathrm D\! \left( A\right) \) are equivalent.

Proof

We can simply give functions back and forth. Note that endofunctions on \(\mathrm D\! \left( A\right) \) that correspond to \(\mathsf {later}\) and “remove \(\mathsf {later}\), if there is one” can be mimicked for \(\mathsf {Seq}_A\): let us use the names \( shift \) and \( unshift : \mathsf {Seq}_A \rightarrow \mathsf {Seq}_A\) for the functions that are determined by , , and .

Define \(j : \mathrm D\! \left( A\right) \rightarrow \mathsf {Seq}_A\) such that \(j(\mathsf {now}(a))\) equals \(\lambda n . \mathsf {inl}(a)\), and \(j(\mathsf {later}(x))\) equals \( shift (j(x))\), One way to do this is to define \(j(z)_n\) by recursion on n, followed by case distinction on z. Furthermore, define \(h : \mathsf {Seq}_A \rightarrow \mathrm D\! \left( A\right) \) in the following way: Given \(s : \mathsf {Seq}_A\), do case distinction on \(s_0\). If \(s_0\) is \(\mathsf {inl}(a)\), return \(\mathsf {now}(a)\). Otherwise, return \(\mathsf {later}(h( unshift (s)))\). It is straightforward to show that j and h are inverses of each other.    \(\square \)

As an aside, our formalisation shows that Lemma 10 holds even if A is not a set.

Next, we mimic the relation \(\downarrow _{\mathrm D}\) by setting

The relation \(\downarrow _{\mathsf {Seq}{}}\) is not in general propositional. To remedy this, we can truncate and consider \({||}{s \downarrow _{\mathsf {Seq}{}} a}{||}\). Using strategies explained by Kraus et al. [15], we have \({||}{s \downarrow _{\mathsf {Seq}{}} a}{||} \rightarrow s \downarrow _{\mathsf {Seq}{}} a\), so we can always extract a concrete value of n: a variant of the definition above in which the number n is required to be minimal is propositional, and this definition can be shown to be logically equivalent to both \({||}{s \downarrow _{\mathsf {Seq}{}} a}{||}\) and \(s \downarrow _{\mathsf {Seq}{}} a\). See the formalisation for details.

We define the propositional relations \(\sqsubseteq _{\mathsf {Seq}{}}\) and \(\sim _{\mathsf {Seq}{}}\) by

By checking that the equivalence from Lemma 10 maps \(\sim _{\mathsf {Seq}{}}\)-related elements to \(\sim _{\mathrm D}\)-related elements, we get:

Lemma 11

The sets \({\mathsf {Seq}_A}/{\sim _{\mathsf {Seq}{}}}\) and \({\mathrm D\! \left( A\right) }/{\sim _{\mathrm D}}\) are equivalent.    \(\square \)

4.2 Monotone Sequences and the QIIT Construction

As the final step of showing that \({\mathrm D\! \left( A\right) }/{\sim _{\mathrm D}}\) and \(A_{\bot }\) are equivalent, we show that \({\mathsf {Seq}_A}/{\sim _{\mathsf {Seq}{}}}\) and \(A_{\bot }\) are. The plan is as follows: There is a canonical function \(w : \mathsf {Seq}_A \rightarrow A_{\bot }\) which can be extended to a function \(\tilde{w} : {\mathsf {Seq}_A}/{\sim _{\mathsf {Seq}{}}} \rightarrow A_{\bot }\). The function \(\tilde{w}\) is injective. Furthermore, if we assume countable choice, then the function w, and thus also \(\tilde{w}\), are surjective. Thus \(\tilde{w}\) is an equivalence.

Let us start by constructing w and \(\tilde{w}\). We use a copairing function \(\left[ \eta \mid \bot \right] : A + \mathbf {1}\rightarrow A_{\bot }\) defined by and , and define \(w : \mathsf {Seq}_A \rightarrow A_{\bot }\) by , with a canonical proof of monotonicity.

Lemma 12

The function w is monotone: \(\varPi _{s,t:\mathsf {Seq}_A} \, s \sqsubseteq _{\mathsf {Seq}{}} t \rightarrow w(s) \sqsubseteq w(t)\). Thus w extends to a map \(\tilde{w} : {\mathsf {Seq}_A}/{\sim _{\mathsf {Seq}{}}} \rightarrow A_\bot \).

Proof

For the second claim we show that w maps elements related by \(\sim _{\mathsf {Seq}{}}\) to equal elements. This follows from the first claim by antisymmetry. For the first claim it suffices to find a function \(k : \mathbb {N}\rightarrow \mathbb {N}\) such that, for all n, we have \(\left[ \eta \mid \bot \right] (s_n) \sqsubseteq \left[ \eta \mid \bot \right] (t_{k(n)})\). Fix n. If \(s_n\) is \(\mathsf {inr}(\star )\), then \(\left[ \eta \mid \bot \right] (s_n)\) is \(\bot \), and k(n) can thus be chosen arbitrarily. If \(s_n\) is \(\mathsf {inl}(a)\), then we have \(s \downarrow _{\mathsf {Seq}{}} a\) and therefore \(t \downarrow _{\mathsf {Seq}{}} a\), which gives us a number k(n) such that \(t_{k(n)} = \mathsf {inl}(a)\) and \(\left[ \eta \mid \bot \right] (s_n) = \eta (a) = \left[ \eta \mid \bot \right] (t_{k(n)})\).    \(\square \)

Lemma 13

The function \(\tilde{w}\) is injective: \(\varPi _{s,t : {\mathsf {Seq}_A}/{\sim _{\mathsf {Seq}{}}}} \, \tilde{w} (s) = \tilde{w} (t) \rightarrow s = t\).

Proof

It suffices to show that, for \(s,t : \mathsf {Seq}_A\), \(w(s) = w(t)\) implies \(s \sim _{\mathsf {Seq}{}} t\). By symmetry, it is enough to fix a : A and show \({||}{s \downarrow _{\mathsf {Seq}{}} a}{||} \rightarrow {||}{t \downarrow _{\mathsf {Seq}{}} a}{||}\), which follows from \(s \downarrow _{\mathsf {Seq}{}} a \rightarrow {||}{t \downarrow _{\mathsf {Seq}{}} a}{||}\). If \(s \downarrow _{\mathsf {Seq}{}} a\) then \(w(s) = \eta (a)\), and thus also \(w(t) = \eta (a)\). Using Lemma 7 and Corollary 8 we then get \({||}{\varSigma _{n:\mathbb {N}} \, \eta (a) = \left[ \eta \mid \bot \right] (t_n)}{||}\), which implies \({||}{\varSigma _{n:\mathbb {N}} \, t_n = \mathsf {inl}(a)}{||}\).    \(\square \)

Lemma 14

Under countable choice, w is surjective: \(\varPi _{x : A_\bot } \, {||}{\varSigma _{s : \mathsf {Seq}_A} \, w(s) = x}{||}\).

Proof

We apply the simplified induction principle presented in Lemma 3. The propositional predicate is . Both \(P(\bot )\) and \(P(\eta (a))\) are trivial: in the first case we use the sequence that is constantly \(\mathsf {inr}(\star )\), while in the second case we take the one that is constantly \(\mathsf {inl}(a)\).

The interesting part is to show \(P\left( \bigsqcup (f,p)\right) \) for a given \(f : \mathbb {N}\rightarrow A_{\bot }\) and \(p : \varPi _{n : \mathbb {N}} \, f_n \sqsubseteq f_{n+1}\). By the mentioned induction principle, we can assume \(\varPi _{n : \mathbb {N}} \, P(f_n)\), which unfolds to \(\varPi _{n:\mathbb {N}} \, {||}{\varSigma _{t : \mathsf {Seq}_A} \, w(t) = f_n}{||}\). By countable choice, we can swap \(\varPi _{n:\mathbb {N}}\) and \({||}{-}{||}\), which allows us to remove the truncation completely, because the goal is propositional. Hence we can assume \(\varPi _{n:\mathbb {N}} \, \varSigma _{t : \mathsf {Seq}_A} \, w(t) = f_n\).

Using the usual distributivity law for \(\varPi _{} \, \) and \(\varSigma _{} \, \) (sometimes called the “type-theoretic axiom of choice”), we can assume that we are given \(g : \mathbb {N}\rightarrow \mathsf {Seq}_A\) and a proof \(\gamma : \varPi _{n:\mathbb {N}} \, w(g_n) = f_n\). By dropping the monotonicity proof and uncurrying, g gives us a function \(g' : \mathbb {N}\times \mathbb {N}\rightarrow A + \mathbf {1}\) with the property that it assumes at most one value in A: If \(g'_{i,j} = \mathsf {inl}(a)\), then (using \(\gamma \)) \(\eta (a) \sqsubseteq f_i\), thus \(\eta (a) \sqsubseteq \bigsqcup (f,p)\), and hence \(\bigsqcup (f,p) = \eta (a)\) by Corollary 8. If we also have \(g'_{k,m} = \mathsf {inl}(b)\), then \(\eta (a) = \eta (b)\), which by Corollary 8 implies that \(a = b\).

We use \(g'\) to construct an element of \(\mathsf {Seq}_A\). Take an arbitrary isomorphism \(\sigma : \mathbb {N}\rightarrow \mathbb {N}\times \mathbb {N}\) (a split surjection would also be sufficient), and define a function \(\tilde{g} : \mathbb {N}\rightarrow A + \mathbf {1}\) by

The intuition is that \(\tilde{g}(n)\) checks the first \(n + 1\) results of \(g' \circ \sigma \) and chooses the last which is of the form \(\mathsf {inl}(-)\), if any, otherwise returning \(\mathsf {inr}(\star )\). Because \(g'\) assumes at most one value in A we get that \(\tilde{g}\) is monotone, \(q : \mathsf {ismon}(\tilde{g})\). Furthermore \((\tilde{g}, q) \downarrow _{\mathsf {Seq}{}} a\) holds if and only if we have \(\varSigma _{n:\mathbb {N}} \, g'(\sigma _n)=\mathsf {inl}(a)\).

In order to complete the proof of \(P\left( \bigsqcup (f,p)\right) \) we show that \(w(\tilde{g}, q) = \bigsqcup (f,p)\) by using antisymmetry:

  • First part: \(w(\tilde{g}, q) \sqsubseteq \bigsqcup (f,p)\). After unfolding the definition of w we see that it suffices to prove \(\left[ \eta \mid \bot \right] (\tilde{g}_n) \sqsubseteq \bigsqcup (f,p)\) for an arbitrary \(n : \mathbb {N}\). If \(\tilde{g}_n\) is \(\mathsf {inr}(\star )\), then this is trivial. If \(\tilde{g}_n\) is \(\mathsf {inl}(a)\) for some a : A, then we can find a pair (ij) such that \(g'_{i,j} = \mathsf {inl}(a)\). Thus we get the following chain:

    $$\begin{aligned} \left[ \eta \mid \bot \right] (\tilde{g}_n) \; = \; \left[ \eta \mid \bot \right] (g'_{i,j}) \; \sqsubseteq \; w(g_i) \; = \; f_i \; \sqsubseteq \; \bigsqcup (f,p) \end{aligned}$$
  • Second part: \(\bigsqcup (f,p) \sqsubseteq w(\tilde{g}, q)\). Given \(n : \mathbb {N}\), we show that \(f_n \sqsubseteq w(\tilde{g}, q)\). By \(\gamma _n\) we have \(f_n = w(g_n)\). Thus it suffices to prove \(w(g_n) \sqsubseteq w(\tilde{g}, q)\), which by Lemma 12 follows if \(g_n \sqsubseteq _{\mathsf {Seq}{}} (\tilde{g}, q)\). If \(g_n(i) = \mathsf {inl}(a)\) for some i and a, then we have \(\mathsf {inl}(a) = g'_{n,i} = g'(\sigma (\sigma ^{-1}_{n,i}))\), and thus \((\tilde{g}, q) \downarrow _{\mathsf {Seq}{}} a\).    \(\square \)

This immediately shows that \(\tilde{w}\) is surjective as well. Putting the pieces together, we get the main result of this section:

Theorem 15

In the presence of countable choice the map \(\tilde{w}\) is an equivalence. Hence the three sets \({\mathrm D\! \left( A\right) }/{\sim _{\mathrm D}}\), \({\mathsf {Seq}_A}/{\sim _{\mathsf {Seq}{}}}\) and \(A_\bot \) are equivalent.

Proof

A function between sets is an equivalence exactly if it is surjective and injective. This is a special case of Theorem 4.6.3 in the HoTT book [20], which states that a function between arbitrary types is an equivalence if and only if it is surjective and an embedding, which for sets is equivalent to being injective.    \(\square \)

5 Applications

The following examples show that our construction can be used in formalisations.

5.1 Nonterminating Functions as Fixed Points

Partiality algebras can be used to implement not necessarily terminating functions. Let \((Y, \sqsubseteq _Y, \bot _Y, \eta _Y, \bigsqcup _Y)\) be a partiality algebra, and let \(\varphi : Y \rightarrow Y\) be a monotone and \(\omega \)-continuous function. We can write down the least fixed point of \(\varphi \) directly as \(\bigsqcup _Y (\lambda n . \varphi ^n(\bot _Y) , p)\), where p is constructed from the fact that \(\bot _Y \sqsubseteq _Y \varphi (\bot _Y)\) and from the monotonicity proof of \(\varphi \). One does not need \(\omega \)-continuity to write down this expression, but we use it to prove that the expression is a fixed point of \(\varphi \).

If \((Y, \sqsubseteq _Y, \bot _Y, \eta _Y, \bigsqcup _Y)\) is a partiality algebra and X is any type, then the function space \(X \rightarrow Y\) can be given the structure of a partiality algebra in a canonical way (this is done for dependent types \(\varPi _{x:X} \, Y(x)\) in the formalisation). As an example of how this kind of partiality algebra can be used we will construct a function \( search _q: A^\omega \rightarrow A_{\bot }\) that takes an element of the coinductive set of streams \(A^\omega \) and searches for an element of the set A satisfying the decidable predicate \(q : A \rightarrow \mathbf {2}\). The function is constructed as the least fixed point of the following endofunction on \(A^\omega \rightarrow A_{\bot }\):

It is straightforward to check that \(f \sqsubseteq g\) implies \(\varPhi (f) \sqsubseteq \varPhi (g)\) by applying \(\varPhi (f)\) and \(\varPhi (g)\) to a point and doing case analysis on q(a). Thus \(\varPhi \) is monotone. In a similar way one can verify that \(\varPhi \) is \(\omega \)-continuous.

5.2 Functions from the Reals

Let us consider the Cauchy reals, defined as a quotient. We say that \(f : \mathbb {N}\rightarrow \mathbb {Q}\) is a Cauchy sequence if, for all m, \(n : \mathbb {N}\) with \(m < n\), we have \(-1 < m \cdot (f_m - f_n)\) \(< 1\). Furthermore, f and g are equivalent (written \(f \sim g\)) if, for all \(n : \mathbb {N}\), we have \(-2 \le \) \(n \cdot (f_n - g_n) \le 2\). We use the notation \(\mathbb {R}^q\) for the quotient of Cauchy sequences by \(\sim \).

A meta-theoretic result is that, without further assumptions, any definable function (i.e. any closed term) of type \(\mathbb {R}^q\rightarrow \mathbf {2}\) is constant for reasons of continuity [16]. In particular, we cannot define a function \( isPositive \) which checks whether a real number is positive. However, we can define a function \( isPositive : \mathbb {R}^q\rightarrow \mathbf {2}_{\bot }\) such that \( isPositive (r)\) is equal—but not judgmentally/definitionally equal—to \(\eta (1_{\mathbf {2}})\) if r is positive, \(\eta (0_{\mathbf {2}})\) if r is negative, and \(\bot \) if r is zero.

We define this function as follows: Given a Cauchy sequence \(f : \mathbb {N}\rightarrow \mathbb {Q}\), we construct a new sequence \(\overline{f} : \mathbb {N}\rightarrow \{-, ?, +\}\). The idea is that \(\overline{f}_n\) is an approximation which only takes \(f_i\) with \(i \le n\) into account. We start with . If we have chosen \(\overline{f}_{n-1}\) to be −, then we choose \(\overline{f}_n\) to be − as well, and analogously for \(+\). If we have chosen \(\overline{f}_{n-1}\) to be ?, we check whether \(f_n \cdot n < -2\), in which case we choose \(\overline{f}_n\) to be −; if \(f_n \cdot n > 2\), we choose \(\overline{f}_n\) to be \(+\); otherwise, we choose \(\overline{f}_n\) to be ?. We can compose with the map \(\{-,?,+\} \rightarrow A_{\bot }\) which is defined by \(- \mapsto \eta (0_{\mathbf {2}})\), \(? \mapsto \bot \), and \(+ \mapsto \eta (1_{\mathbf {2}})\). This defines a monotone sequence in \(\mathbf {2}_{\bot }\), and we can form \(\bigsqcup \overline{f} : \mathbf {2}_{\bot }\) to answer whether f represents a positive or negative number, or is zero. One can check that equivalent Cauchy sequences get mapped to equal values, hence we get \( isPositive : \mathbb {R}^q\rightarrow \mathbf {2}_{\bot }\).

The strategy outlined above does not quite work for the reals defined as a HIIT [20] because, roughly speaking, in that setting \(f_n\) is a real number and a comparison such as \(f_n \cdot n < -2\) is undecidable. Recently Gilbert has refined our approach and defined a function \( isPositive \) for such reals [13], using the definition of the partiality monad presented in this text (with insignificant differences). Gilbert’s key observation is that comparisons between real numbers and rational numbers are semidecidable, and semidecidability is sufficient to define \( isPositive \).

5.3 Operational Semantics

In previous work the second-named author has discussed how one can use the delay monad to express operational semantics as definitional interpreters [11]. As a case study we have ported some parts of this work to the partiality monad discussed in the present text: definitional interpreters for a simple functional language and a simple virtual machine, a type soundness proof, a compiler, and a compiler correctness result. Due to lack of space we do not include any details here, but refer interested readers to the accompanying source code.

6 Discussion and Further Work

We have constructed a partiality monad without using countable choice. This is only a first step in the development of a form of constructive domain theory in type theory. It remains to be seen whether it is possible to, for instance, replicate the work of Benton et al. [5], who develop domain theory using the delay monad.

Consider the partial function \( filter : \varPi _{A : \mathsf {Set}} \, (A \rightarrow \mathbf {2}) \rightarrow A^\omega \rightarrow A^\omega \) that filters out elements from a stream. How should partial streams over A be defined? Defining them as \(\nu X. (A \times X)_{\bot }\) seems inadequate, because the ordering of \((-)_{\bot }\) is flat. One approach would perhaps be to define this type by solving a domain equation. Instead of relying on the type-theoretic mechanism to define recursive types, we can perhaps construct a suitable type of partial streams as the colimit of an \(\omega \)-cocontinuous functor on the category of \(\omega \)-cpos. Preliminary investigations indicate that QIITs are useful in the endeavour, for example in the definition of a lifting comonad on \(\omega \)-cpos (as suggested by Paolo Capriotti).

Going in another direction, it might be worth investigating how much topology can be done using the Sierpinski space, represented as \(\mathbf {1}_{\bot }\) in our setting. A very similar question was discussed at the Special Year on Univalent Foundations of Mathematics at the IAS in Princeton (2012–2013). Moreover, some observations have been presented by Gilbert [13], who used our definition of \(\mathbf {1}_{\bot }\) as presented in this paper (with minor differences).