Cost-sensitive computational adequacy of higher-order recursion in synthetic domain theory
Abstract
We study a cost-aware programming language for higher-order recursion dubbed in the setting of synthetic domain theory (SDT). Our main contribution relates the denotational cost semantics of to its computational cost semantics, a new kind of dynamic semantics for program execution that serves as a mathematically natural alternative to operational semantics in SDT. In particular we prove an internal, cost-sensitive version of Plotkin’s computational adequacy theorem, giving a precise correspondence between the denotational and computational semantics for complete programs at base type. The constructions and proofs of this paper take place in the internal dependent type theory of an SDT topos extended by a phase distinction in the sense of Sterling and Harper. By controlling the interpretation of cost structure via the phase distinction in the denotational semantics, we show that programs also evince a noninterference property of cost and behavior. We verify the axioms of the type theory by means of a model construction based on relative sheaf models of SDT.
keywords:
compositional cost analysis, domain theory, synthetic domain theory, type theory, PCFAcknowledgements. This work was funded by the United States Air Force Office of Scientific Research under grants FA9550-23-1-0728111Dr. Tristan Nguyen, Program Manager, MURI FA9550-21-0009Footnote 1, FA9550-21-1-0385Footnote 1 and the National Science Foundation under grant CCF-1901381. We thank Tristan Nguyen at AFOSR for support. Yue Niu was supported by the Air Force Research Laboratory through the NDSEG fellowship. Views and opinions expressed are however those of the authors only and do not necessarily reflect those of AFOSR, AFRL, or NSF.
1 Introduction
In 1977 Plotkin [22] introduced a programming language for higher-order recursion, PCF, and defined computational adequacy, a fundamental notion relating the denotational and operational semantics of a programming language in terms of the computational behavior of closed programs of ground type. Since Plotkin’s seminal work, computational adequacy has been developed and refined to tailor various programming features and is an important property in the context of denotational approaches to program verification, enabling one to bring familiar mathematical structures and equational reasoning to bear on problems regarding program behavior. One refinement takes place in both the arrangement and metatheory of the semantics. In one direction, when the ambient category in which the model is defined has sufficient logical structure, one may view the object programming language from an internal perspective, a situation that was first thoroughly developed in the context of synthetic domain theory [11, 20]. In the other direction, one may move to a constructive metatheory such as the internal languages of generic elementary topoi or guarded type theory. The transition to these constructive, internal versions of computational adequacy has several benefits. First, by working inside topoi or type theories, one is automatically equipped with a powerful logical language to reason directly about domains and the denotational semantics, which was one of the original motivations for the development of synthetic domain theory. Second, the constructive nature of the metatheory means that one can argue that computationally adequate denotational semantics can be directly executed, as observed by De Jong [2] in his work on constructive domain theory.
Computational adequacy in cost analysis. More recently, Niu and Harper [17] identified another application of internal adequacy in the context of cost analysis in calf [18], a type theory in which cost is reified as a computational effect and cost analysis takes the form of equational reasoning. A natural question in this setting is the relationship between the abstract cost bounds specified and proved in calf and the concrete bounds derived with respect to traditional operationally-based cost models. Viewing calf as a semantic universe for internal denotational semantics, Niu and Harper [17] determined a criterion justifying the adequacy of an abstract calf cost model with respect to operational semantics by means of a cost-sensitive refinement of computational adequacy, which they instantiate using a variant of the Algol programming language, which featured higher-order (total) functions, first-order store and while loops.
1.1 Motivations
The aim of the present work is to extend the results of Niu and Harper [17] to full higher-order recursion by combining their ideas with synthetic domain theory, culminating in a type theory for computing with generalized spaces that support cost instrumentation alongside an information order for recursion.
1.1.1 Types as generalized spaces
The type theoretic philosophy is to study a real phenomenon in terms of abstract interfaces rendered as types; type theoretic terms, then, correspond precisely to constructions in this discourse that preserve the geometrical and topological structure at play. For example, in synthetic domain theory (SDT), types have an intrinsic topology with respect to which all functions are continuous. By adhering to an abstract interface, the type-theoretic viewpoint brings to the fore the essential logical/geometric structure of underlying objects of interest and suppresses ill-defined objects and transformations, which makes it possible to define and reason about the domain of discourse in a conceptually simple manner that is completely rigorous.
Orthogonal to the topological and order-theoretic aspects of types as spaces in synthetic domain theory, we shall impose a different kind of geometric structure called a phase distinction. Originating in the theory of program modules and logical relations [9, 31], a phase distinction can generally refer to any situation in which types represent indexed structures. For example, a program module can be represented as a family of dynamic runtime components whose “shape” is determined/indexed by a static module signature; similarly, a logical relation of a type theory can be represented as a family of computability data indexed in a syntactic type. In this work, we are concerned with a similar kind of phase distinction called the intension-extension phase distinction, introduced by Niu et al. [18] to enable simultaneous reasoning about both the cost and extensional behavior of programs.
The geometric aspect of phase distinctions emerges through two operations, restriction and sealing, that manipulate types to either trivialize the fibers or the base of the indexed structure represented by a given type. In the present case, these two operations are used to implement a form of cost profiling semantics for programs that can be easily “stripped away” via restriction, enabling one to simultaneously and faithfully carry out cost analysis in one framework; we shall describe this in mathematical terms in Section 1.2.1.
In this paper we combine the intension-extension phase distinction of Niu et al. [18] with the domain-theoretic structure of SDT to obtain an intrinsically cost-sensitive theory of higher-order recursion in type theory. There are two main motivations for this combination. First, building on the work of Niu et al. [18, 17] we obtain an account of cost analysis in type theory that is compatible with general recursive programs, which we anticipate will enable more natural programming and verification techniques. Second, we will use the resulting type theory to define and study the internal denotational semantics of , a cost-aware version of PCF, and prove a cost-sensitive internal computational adequacy theorem in the sense of op. cit. We explain what this entails in the following section.
1.1.2 Internal denotational semantics
By internal denotational semantics, we mean to specify the syntax and semantics of a given programming language called the object language as constructions internal to type theory. Typically, one may define the syntax of the object language by means of a first-order encoding in terms of (indexed) inductive data types in which we have a type of object-level types and a type family of object-level terms. A denotational model of is given by a pair of maps and sending types to semantic domains and terms to elements of semantic domains. Usually we will use to refer to either map when the context is unambiguous. Similarly, one may define an internal operational semantics of as a type family such that the type (viewed as a proposition) holds just when evaluates to .
Computational adequacy, first introduced in Plotkin [22], is a statement that relates the operational and denotational semantics of at the type of booleans (or any other observable type): a denotational semantics is computationally adequate when just when , where is the object-level boolean denoted a semantic boolean . In the context of program verification, computational adequacy is a desirable property because the agreement of both semantics at observable types can be used to justify semantic reasoning with respect to operational behavior. In the context of cost analysis, the significance of this property is made explicit in the work of Niu and Harper [17], where the authors illustrate how a cost-sensitive refinement of internal computational adequacy can serve as the basis for validating user-defined cost models and program cost instrumentations. At a high level, results of this kind serve to ground the abstract reasoning supported by type theory to “reality” as given by operational semantics; we defer to op. cit. for a deeper discussion.
In this paper we will generalize the result of Niu and Harper [17] to higher-order recursion. In contrast to op. cit., in this paper we prefer to work with a version of whose execution model is given by a computational semantics (see Section 7). We will elaborate on the relationship between this new kind of dynamic semantics and traditional operational semantics in Section 10.
1.2 Mathematical techniques
In constructing a model for the type theory supporting both a phase distinction and recursion, we employ mathematical tools that deserve some explication, which we summarise below.
1.2.1 Cost as a phase distinction
The writer monad on a monoid is a well-established way to express the computational effect of incurring and accumulating the cost of program execution. However, as pointed out by Niu et al. [18], this arrangement does not faithfully model the semantics of cost profiling because it allows functions to branch on the cost component of their inputs. Thus, semantic functions lack a coherent underlying behavior independent of the profiling, which is indispensable for stating behavioral or correctness specifications of algorithms.
In the calf type theory of Niu et al. [18] this problem is resolved by means of the intension-extension phase distinction, as discussed in Section 1.1.1. Mathematically, a type-theoretic phase is simply a distinguished proposition whose associated open and closed modalities [26] generate subuniverses for classifying purely extensional and purely intensional types, respectively. A purely extensional type does not detect the presence of the phase proposition in the sense that the map sending to the constant map determined by is an isomorphism; in other words a purely extensional type classifies only the behavior of programs. By contrast, a purely intensional type “collapses” extensionally in the sense that . Given any type , one may extract from the purely extensional and purely intensional part of by means of idempotent monadic modalities. The extensional/restriction modality is simply defined as the function space out of the proposition: (i.e. the reader monad on ). The intensional/sealing modality is defined as the following pushout/quotient inductive type (QIT) [4]: The universal property of the sealing monad can be phrased in terms of a unique extension property: for any map into a purely intensional type , there is a unique extension along the unit of the sealing monad . One can use the phase proposition to exhibit a form of noninterference in the sense of information flow: any map from a purely intensional type to the extensional part of must be constant. Therefore in calf one achieves a semantically faithful instrumentation of cost by programming against the writer monad on a purely intensional cost monoid.
From an external point of view, calf’s types can be modeled as presheaves on the interval ; in the terminology of Sterling and Harper [32], such a presheaf encodes a set varying in the intension-extension “security poset” whose presheaf restriction action redacts intensional cost structure. The phase proposition is given by the “intermediate” proposition corresponding to the representable .
1.2.2 Synthetic domain theory
Synthetic domain theory (SDT) as a field started when Dana Scott conjectured that one ought to be able to reason about domains as if they were just sets provided that one employs a constructive ambient metalanguage. In technical terms, this metalanguage can be construed as the internal languages of a topos, i.e. an extensional dependent type theory. In general it is difficult to reconcile the domain-theoretic structure with the rich logical structure of dependent type theory, so the quest for SDT was in essence about constructing full subcategories of topoi that supported domain-theoretic constructions. Fullness is a critical property — it means that every map definable in type-theoretic language is a domain morphism, which absolves one from checking onerous side conditions when working internally. There are two well-known ways to obtain models of synthetic domain theory: one based on realizability (Hyland [11], Phoa [20], Reus [24]) and one based on sheaf topoi (Rosolini [27], Fiore and Rosolini [7], Fiore and Plotkin [5], Matache et al. [16]). In this paper we will construct a sheaf model of SDT, so we take a moment to recall the basic ideas, mainly drawing from the work of Fiore and Plotkin [5].
Sheaf models of SDT. The intuition behind (pre)sheaf models of synthetic domain theory is to use the Yoneda embedding to embed a category of predomains as a full subcategory of an ambient category whose internal language is dependent type theory. Thus given a (small222The fact that natural categories of predomains are rarely small can be overcome by means of Grothendieck universes or a small dense subcategory (e.g. ).) category of predomains , the category of presheaves on presents the original category of predomains as a full subcategory, which constitutes a simple model of SDT. However there are some strange properties of this model from an internal perspective. For example, because the is the initial object in , it is a sub-predomain of every other predomain. But because the embedding does not preserve colimits, the subcategory of predomains does not contain an initial object from the perspective of ; in other words, this means that while the empty set is a subset of every predomain, it is not a sub-predomain, which obstructs the use of the ambient logic to reason about (pre)domains. We may repair the model by imposing a nontrivial Grothendieck topology on that ensures that the empty predomain is preserved by the embedding into the category of sheaves on . In practice one may choose to preserve additional colimits as the application demands — for instance in Section 9 we will construct a model of SDT in which discrete finite predomains are preserved.
1.2.3 Predomains and the intrinsic order
Contrary to classical domain theory, ordering on predomains is a derived notion in synthetic domain theory. Nonetheless one may equip a synthetic predomain with an intrinsic preorder that is analogous to the information order of ordinary predomains. By default the intrinsic/synthetic preorder is not very well-behaved: it is not pointwise on limits of predomains, and it is not even a partial order in general. In this paper we shall define and base our constructions on a notion of synthetic predomains for which the intrinsic preorder is extremely well-behaved: it is pointwise, partially ordered, and closed under synthetic -chains, which is the counterpart to closure under -chains for classic -cpos.
Aside from intrinsic interest, we are motivated by two practical incentives for considering and developing the theory of the synthetic preorder. First, we would like to connect our work to the type theory for cost analysis developed by Grodin et al. [8]. In that setting one works with a cost ordering on programs in which represents a proof of the fact that is an upper bound of with respect to computational cost. We expect that one may extend the work of op. cit. to account for recursive programs by the methods we develop in this paper, and the information/intrinsic preorder appears to be the correct theoretical framework for describing the interaction of cost and partiality [13, Section 8]. Second, the advantages of the synthetic point of view outlined Section 1.2.2 do not detract from the benefits of the language of classical domain theory. The intrinsic preorder integrates the advantages of both the synthetic and classical perspective by providing an intuitively appealing language for reasoning about domains that automatically complies with well-definedness conditions such as monotonicity and continuity.
1.2.4 Synthetic predomains from orthogonality
From an internal perspective, predomains in a model of SDT [5, 25, 32] are often defined in terms of (internal) orthogonality conditions. Intuitively, an orthogonality condition can be thought of as a way of specifying a closure property with respect to a given figure shape . A type is orthogonal to a map when is invertible. In other words is orthogonal to when “thinks” is an isomorphism. For instance, an -cpo is a poset that is orthogonal to the figure shape , i.e. when is closed under joins of -chains. In Section 3 we define predomains by means of multiple such orthogonality conditions. The benefit of this general approach to synthetic domain theory is that subcategories defined by (internal) orthogonality conditions are automatically (internally) reflective — this closes the predomains under structures necessary for day-to-day denotational semantics such as product and function types. Moreover, limits of predomains are preserved by the inclusion into the ambient SDT topos, which allows one to reason about the denotational semantics in a straightforward way using the internal language. Note that colimits of predomains always exist by virtue of the reflection, but they are usually not preserved by inclusion; in some situations this may be calibrated by ensuring a precise correspondence between the original domain-theoretic site and the subcategory of predomains (e.g. the internal characterization of -cpos of Fiore and Rosolini [6]).
1.3 Contributions
The contribution of our work is summarized as follows:
-
\normalshape(1)
An axiomatization of a type theory based on SDT that incorporates both a phase distinction and a subuniverse of predomains whose intrinsic order structure is well-behaved (Section 2).
-
\normalshape(2)
A denotational semantics for exhibiting noninterference between cost and behavior (Section 6).
-
\normalshape(3)
A dynamic semantics for in which execution is modeled directly as computation (Section 7).
-
\normalshape(4)
An internal cost-sensitive adequacy theorem identifying the two semantics at base type (Section 8).
-
\normalshape(5)
A relative sheaf model of SDT justifying the axioms of the type theory (Section 9).
2 A type theory for cost-sensitive synthetic domain theory
We work in an extensional dependent type theory combining synthetic domain theory with the intension-extension phase distinction of Niu et al. [18]; the semantics and model construction of this theory is developed in Section 3 and Section 9. Here we outline the language furnished by this combination. Following Niu et al. [18], we assume an indeterminate proposition representing the phase distinction. We assume a (reflective) subuniverse of predomains . Every predomain is equipped with a synthetic -complete partial order structure, which we explain in Section 4.3. The significance of synthetic -completeness is that they can be used to construct the join of rational chains (-chains arising from the iterates of an endomap), the critical component in the interpretation of fixed-points in both classical and synthetic domain theory.
By a domain we shall mean a predomain equipped with a least element. Equivalently this may be characterized as an algebra for the lifting monad , which freely adjoins a least element to a predomain. There is a special domain spanned by propositions called the Sierpiński space or dominance; propositions in should be thought of as the support of partial maps, and a map can be thought of as a “computational” or “observable” subset of a predomain . Moreover, because we use the sealing modality (see Section 1.2.1) associated with the phase proposition to define the denotational cost semantics of PCF, we require that predomains are closed under the sealing modality. Lastly, we assume that the subuniverse is closed under lifting.
2.1 Denotational semantics of cost-sensitive PCF
We aim to prove the computational adequacy property for a cost-sensitive version of PCF called in which cost and partiality are treated as a single call-by-push-value effect. We spell out the details of the language in Section 5, but the basic idea is to separate pure values and effectful computations at both the term and type level, resulting in a class of value types and a class of computation types . The type structure of the language is generated by a pair of type operators in which represents the partial cost-aware computations of type and represents the value type whose underlying set of points are computations of type . In contrast to call-by-value languages, call-by-push-value function types are computations and take the form . As an example, the ordinary call-by-value PCF function type corresponds to the type in the call-by-push-value setting — here the codomain type records both the cost incurred and the possibility of divergence, and the outer corresponds to the fact that functions are values in a call-by-value setting.
The denotational semantics of is based on the adjunction models of call-by-push-value [14] in which is defined to be the lift of for a purely intensional cost monoid in the sense of Section 1.2.1. By using a purely intensional type for the cost semantics, we may prove a cost-sensitive computational adequacy theorem that can be restricted to an extensional adequacy result for PCF. Moreover, by interpreting the cost this way, the resulting denotational cost semantics evinces a form of information flow security when viewing cost and behavior as security levels:
Proposition 2.1.
For any purely extensional type , every map is weakly constant in the sense that for any inputs , we have that and are equal whenever they are both defined.
As an application of computational adequacy, we can immediately transfer this intrinsic denotational security property to functions of .
Remark 2.2.
As mentioned in Section 1.1.2, we will define both the syntax and semantics of as objects and functions in the internal type theory of a synthetic domain theory topos. In a more traditional approach to denotational cost semantics, one may instead define a model of in the category of families of -cpos, which is semantically simpler in comparison to models of synthetic domain theory. In this paper we pursue an approach based on the latter in order to unify two strands of prior work — cost-sensitive programming and verification in dependent type theory [18] and internal denotational semantics [19, 17] — and synthetic domain theory provides the means for smoothly integrating higher-order recursion into dependent type theory.
3 Cost-sensitive predomains in synthetic domain theory
As mentioned in the Section 1.2.3, the purpose of this section is to define a notion of predomains in synthetic domain theory such that the intrinsic preorder on predomains is partially ordered, defined pointwise on function spaces, and is closed under suprema of synthetic -chains. We will use these properties to define and reason about admissible subsets of domains. We define the basic notions of synthetic domain theory, and give an axiomatization of the rest of the paper in terms of SDT models of the intension-extension phase distinction, culminating in a category of predomains satisfying the properties laid out above.
3.1 Partial maps, dominance, and lifting
In a category with pullbacks, a partial map is a span consisting of a subset on which is defined. In synthetic domain theory, only certain monomorphisms correspond to domains of definitions of partial maps. In the terminology of Rosolini [27] such a collection is called a dominion:
Definition 3.1.
A pullback-stable collection of monomorphisms is a called a dominion when it is closed under identity and composition.
Definition 3.2.
Let be an elementary topos equipped with a subobject such that . A monomorphism is classified by if and only if its characteristic map factors through . A dominance is a subobject such that the class of monos classified by is a dominion. We call a proposition (resp., predicate) factoring through a -proposition (resp., -predicate).
In the internal language, this means that contains the true proposition and is closed under dependent sums, which we write as given and . These structures ensure that the dominance determines a lifting monad whose action on points are defined as follows:
Definition 3.3.
The lift of a type relative to a dominance is defined as .
The lifting monad is also called the partial map classifier because every partial map with a -subobject of appears as the pullback of for a unique .
Notation 1
Given a partial element , we write for its support, i.e. is the first projection . When it is known that holds, we may write for the defined element.
3.2 Complete types
In synthetic domain theory the structure of predomains is generated not from consideration of -indexed chains but rather a new notion of chains called a synthetic -chain, which is defined simply to be a map out of . The difference between the two notions of chain is elucidated by the fact that is the initial lifting algebra for the dominance of decidable propositions, whereas is the initial algebra for a larger dominance.
Definition 3.4.
A synthetic -chain is a map from the initial -algebra or lift algebra .
The closure properties of synthetic -chains can be captured by considering an orthogonality condition relative to the figure shape induced by the inclusion of the initial lift algebra in the final lift coalgebra . As we alluded to in Section 1.2.4, orthogonality is a way to identify types that “think” certain maps are isomorphisms:
Definition 3.5.
A type is orthogonal to when there is a unique extension of any map to a map such that .
Definition 3.6.
A type is called complete when it is orthogonal to the figure shape , and well-complete when is complete.
Complete types [11, 20] are the synthetic counterpart to -cpos in classic domain theory. The class of well complete types was introduced in Longley and Simpson [15] as the least restrictive possible notion of predomain that is closed under lifting. In this paper we consider the dual most restrictive class of predomain, the replete types [11], in order to obtain a sharper characterisation of the intrinsic order relation (see Section 3.3) on predomains.
Definition 3.7.
A map is called -equable or a -isomorphism when is orthogonal to .
Definition 3.8.
A type is replete when it is orthogonal to every -iso. A predomain is a replete type.
In other words, a predomain respects every -isomorphism; we will use this fact to easily transfer properties that hold of to every predomain in Section 4.
3.3 The intrinsic order
For every type , the dominance induces an intrinsic preorder on analogous to the specialization preorder on a topological space: if and only if implies for every . Viewing as a computational or observable property of , holds whenever satisfies every observable property of . By default the intrinsic preorder is relatively unconstrained — for instance, it need not be a partial order in general and on the dominance it need not coincide with the implication order on propositions. The purpose of this section is to axiomatize some constraints on that will make intrinsic preorder coincide with the implication order on ; this is used in the characterization of the intrinsic order of lifting in Section 4. To this end, we introduce an intermediate path relation on types:
Definition 3.9.
A path in a type is a map . The boundary of a path is the pair . We write when there exists a path whose boundary is .
The path relation is an alternative way to surface the order structure of predomains, studied in much more detail by Fiore [3]; the path relation is also used by Grodin et al. [8] to obtain a theory of synthetic preorders for cost analysis. In this paper one can view the path relation as an auxiliary notion that ultimately coincides with the intrinsic preorder on predomains. In general we call types for which this holds linked, following Phoa [20]:
Definition 3.10.
A type is called linked when the intrinsic preorder coincides with the path relation.
The fact that the intrinsic order on coincides with the implication order follows if is linked. This latter property holds when satisfies one of the fundamental axioms of synthetic domain theory:
Definition 3.11.
The dominance satisfies Phoa’s principle when the boundary evaluation map factors as an isomorphism followed by an inclusion: .
Phoa’s principle expresses the fact that the path space of is fully characterized by ordered pairs of -propositions (with respect to implication). Because the negation of an observable property is not in general observable, Phoa’s principle may be seen as an explicit statement of the constructive/observable nature of -propositions, i.e. there is no map sending to .
Proposition 3.12.
Assuming Phoa’s principle, the dominance is linked.
Corollary 3.13.
Assuming Phoa’s principle, the intrinsic order on is the implication order.
Moreover, the path in associated to every implication is unique in the following sense:
Definition 3.14.
A type is boundary separated when any two paths in sharing a boundary are equal.
Proposition 3.15.
Assuming Phoa’s principle, is boundary separated.
3.4 Axioms of the phase distinction in SDT and predomains
Having developed the axiomatics of the ordinary synthetic domain theoretic components of our work, we now introduce the intension-extension phase distinction as discussed in Section 1.2.1. The meeting point of the domain-theoretic and the cost-sensitive aspects of our work is simply expressed by the requirement that the phase proposition is a -proposition. This allows us to manufacture a purely intensional monoid from a standard cost monoid that we will use to define a denotational semantics for PCF that exhibits the natural information flow security properties with respect to cost and behavior as outlined in Section 2.1.
More specifically, we may use the fact that is a -proposition to define the sealing monad mentioned in Section 1.2.1 that can be seen as the canonical way of making a predomain purely intensional. When defining the denotational semantics, we may then take as an input to the model construction any ordinary monoid (in the subuniverse of predomains) and apply the sealing monad to obtain a purely intensional monoid. Lastly, to exhibit the kind of noninterference property of cost and behavior as discussed in Section 1.2.1, we require that there is a purely extensional base predomain. These considerations lead us to the following axiomatization of our synthetic domain theory topos:
Definition 3.16.
An SDT model of the intension-extension phase distinction is an elementary topos equipped with a dominance satisfying Phoa’s principle such that is complete, and a distinguished -proposition such that the type of booleans is an extensional predomain.
For the rest of the paper we assume a given SDT model of the intension-extension phase distinction . All constructions are all carried out in the internal language of .
4 Properties of predomains
We now establish the expected characterizations of the intrinsic preorder (Section 3.3) on predomains:
-
\normalshape(1)
The intrinsic preorder is pointwise on products, functions, and liftings of predomains.
-
\normalshape(2)
The intrinsic preorder on a predomain is a synthetic -complete partial order.
-
\normalshape(3)
The synthetic -complete partial order structure of predomains is defined componentwise for products and functions between predomains.
The general properties of the intrinsic preorder and link relation in SDT have been investigated in several prior works [20, 24, 15]. Here we recall just a few important properties that we will need.
Proposition 4.1.
Any predomain enjoys the following properties:
-
\normalshape(1)
Completeness: is orthogonal to .
-
\normalshape(2)
Anti-symmetry: the intrinsic preorder on is a partial order.
-
\normalshape(3)
Boundary separation: maps with equal boundary are equal.
-
\normalshape(4)
Linkedness: the intrinsic preorder and the link relation on coincide.
In addition, because predomains are defined in terms of orthogonality conditions, they are closed under (internal) limits and have all colimits, i.e. limits of predomains are computed in the same way as limits of general types. The rest of the section is dedicated to proving the desired properties on the intrinsic order on predomains. Because the intrinsic order and are the same for predomains, we may speak of the synthetic order of predomains and write for this relation in the rest of the paper.
4.1 Discrete predomains
We shall assume that the cost structure of is given as a discrete type in the following sense:
Definition 4.2.
A type is called flat or discrete when implies .
Definition 4.3.
A type has -equality when its equality relation is valued in -propositions.
Proposition 4.4.
Any type with -equality is discrete.
Proof 4.5.
Let be the characteristic map that sends to , which by assumption is a -proposition. Since on the specialization order and holds, we have that holds as well.
The category of predomains possesses a natural numbers type with -equality, which means it is also discrete. Note that it is not necessarily the same as the ambient natural numbers type , and we will not assume that it is the case in our constructions. From a logical perspective, this difference means that has a universal mapping-out property whose motive is valued in predomains rather than arbitrary types.
In Section 6 we will require the cost structure of to be both discrete and purely intensional in the sense of Section 1.2.1; here we show that these are compatible requirements by giving sufficient conditions to obtain a purely intensional discrete type (for instance, will be discrete).
Proposition 4.6.
If has -equality, then so does .
4.2 Characterization of the synthetic order
As mentioned at the beginning of this section, one of the primary motives of using replete types as predomains is to give a compositional characterization of the synthetic order. Roughly this means that the order relation on composite predomains can be defined in terms of the order on the constituent predomains.
Proposition 4.7.
When and are predomains, the synthetic orders on and are pointwise.
We may also give a similar characterization of the order relation on lifted predomains:
Proposition 4.8.
Given a predomain , we have that if and only if implies and whenever , we have .
4.3 The synthetic -complete partial order structure
Every predomain contains the least upper bound of a synthetic -chain; we will use this fact to interpret fixed points of in Section 6.
Proposition 4.9.
For every map into a complete type , there exists an element such that is a least upper bound of with respect to the intrinsic preorder.
Because the intrinsic preorder on a predomain is a partial order by Proposition 4.1, we write for the (necessarily unique) element defined in Proposition 4.9. We note that suprema of synthetic -chains in function spaces are computed pointwise.
4.4 Domains and admissibility
Semantically, recursive functions may be interpreted as the fixed points of endomaps of domains:
Definition 4.10.
A domain is a predomain equipped with a -algebra structure. Every domain contains a least element given by postcomposing the algebra map with the unique undefined element . We write for the least element of .
Proposition 4.11.
Given a map of domains , there is an element such that is the least fixed-point of .
Similar to classical domains, we may introduce a notion of “good subsets” of domains for which fixed-point induction is valid.
Definition 4.12.
A subset of a domain is admissible when it contains and is closed under suprema of synthetic -chains.
Proposition 4.13 (Fixed-point induction).
Given an admissible subset of a domain and , to show that it suffices to show that implies .
4.5 Monotonicity and continuity
As we discussed in Section 1.2.2, one of the main benefits of working in a synthetic domain theory is that maps are automatically compatible with the derived order structure:
Proposition 4.14.
Every map between predomains is monotone in the synthetic order.
Proposition 4.15.
Every map between predomains is continuous in the sense that for every synthetic -chain .
5 : a language for cost-aware higher-order recursion
Our main technical result is the computational adequacy property for , a version of Plotkin’s PCF [22] equipped with an abstract cost effect. The treatment of both cost structure and recursion as a call-by-push-value effect in is inspired by [13]. The syntax of is parameterized in a monoid representing the cost structure; in Section 6 we will impose further properties on when we define the denotational semantics of . As mentioned in Section 2.1, the type structure of is generated by a pair of operators that corresponds semantically to the free-forgetful adjunction between plain sets and the category of partial cost algebras, which are sets equipped with an action for the partial cost monad . The types and terms of are summarized in Fig. 1, defined as inductive definitions in the SDT topos .
6 Cost-aware denotational semantics of
Both the syntax of and our model construction is parameterized in a monoid object representing the cost structure. We require the following conditions to hold:
-
\normalshape(1)
Computational: is a predomain with -equality.
-
\normalshape(2)
Phase separation: is purely intensional, i.e. .
That is computational are used in two places in the computational adequacy proof: when reasoning about the computational semantics of (see Section 7), we need to be discrete (which follows from Proposition 4.4) in order to prove the property that sequential composition of computations may be decomposed (Proposition 7.4), and we need to have -equality when showing that the formal approximation predicates (see Fig. 5) associated to semantic domains are admissible. We require to be purely intensional to ensure that the denotational semantics of exhibits an intrinsic noninterference property of cost and behavior as sketched in Section 2.1. As discussed in Section 3.4, there is a canonical way of turning any monoid into a purely intensional type by means of the sealing monad .
6.1 The partial cost monad
To model partiality and cost as a single effect, the computation types of are interpreted as algebras for the monad whose action on points is defined by composing the lift and the writer monad . The distributive law for and the resulting monad structure is displayed in Fig. 2, where we write for the induced bind operation of a monad where is a map into a free -algebra. We will also write for sequencing and for an -algebra .
6.2 The derived cost algebra
To model the cost effect , we use the fact that every algebra for is canonically an algebra for the writer monad , which is a general property of composite monads defined from a distributive law [1, Section 2]. In our case this means that every -algebra has an underlying cost algebra as well; we write for the cost algebra map.
Proposition 6.1.
The action of the derived cost algebra satisfies the following equations for and for some -algebra :
6.3 Denotational semantics of
The semantics of is based around the free-forgetful adjunction associated with the partial cost monad in which value types are predomains and computation types are -algebra valued in predomains. The essential parts of the model is displayed in Fig. 3. Most of the type structure of is interpreted using the cartesian closed structure of predomains; note that the numerals type is interpreted as the natural numbers type of predomains , which is not the same as the ambient natural numbers .
7 Computational semantics of
Computational adequacy is a property relating the denotational semantics of a language with its execution behavior as given by an operational semantics. Commonly one employs a structural operational semantics [21] in which the operational semantics of a language is defined as an inductive family of relations . Both termination and evaluation can be defined by means of the reflexive transitive closure of the family of relations , which is the smallest reflexive, transitive family of relations containing .
Computational semantics. We consider an alternative formulation of the dynamic semantics of in which execution is modeled not as an inductive family but directly as a (partial) computation. This departure from traditional operational semantics is necessitated by our proof of computational adequacy. As we explain in Section 8.2, termination must be a predicate valued in -propositions; however, the reflexive-transitive closure of a decidable relation (such as ) can only be seen to be a -predicate assuming that is closed under countable joins of decidable propositions that are preserved by the inclusion into the ambient type theory, i.e. for every countable family of -propositions . Our approach bypasses this question by de-emphasizing in favor of the initial lifting algebra , a lesson of Simpson [28]. We discuss the relationship between this computational semantics and ordinary operational semantics in Section 11.
7.1 Computational semantics of
We begin with a family of small-step transition relations that implements the cost effect model in the sense of Hoffmann [10]. The intuitive meaning of is that transitions in one step to and incurs cost ; the only place where cost is effected is at : . The family of relations is defined as an inductive family whose generators are displayed in Fig. 4 (the expected congruence rules have been omitted). We iterate the “one step” relation to obtain the partial map implementing the computational semantics. Because is decidable, we have a characteristic map . Consider the following functional:
Define to be the fixed-point of and as . The meaning of is that when it is defined, computes to a value incurring the defined cost. Similarly, is the cost of computing when the former is defined. In the following, we will establish some expected properties of the computational semantics such as the uniqueness of evaluation and a “big-step” law for sequencing evaluations.
Proposition 7.1.
The relation is functional, i.e. and implies .
Proposition 7.2.
If and , then .
Corollary 7.3.
If and , then .
In ordinary operational semantics, one has the property that implies there exists a value such that and . An analogous rule also holds for the computational semantics, except the value is not existentially quantified:
Proposition 7.4.
The following inference rule is valid for any -predicate : {mathpar} \inferrule (e, v) ∧(g v, (w)) →φ((e, v) + (g v, (w))) (e; g, (w)) →φ((e; g, (w)))
Using this rule we may derive the following law for profiling compound sequences:
Proposition 7.5.
We have .
8 Computational adequacy and noninterference
In this section we show that the computational and denotational semantics satisfy a tight correspondence at the type of observations: for every , we have that is Kleene equivalent to in the sense that the cost specified computationally and denotationally are equal whenever one of them is defined.
8.1 Soundness
In one direction, it is not too difficult to show soundness, which means that the computational steps are respected by the denotational semantics:
Proposition 8.1.
If , then .
Theorem 8.2.
If , then .
Corollary 8.3.
Given , we have .
8.2 Adequacy
Adequacy proper usually refers to the converse direction of the property stated in Corollary 8.3: definedness of the denotational semantics implies termination under the computational semantics. Our proof is based on a standard binary logical relations construction between the syntax and semantics of (cf. Plotkin [22]). The logical relation consists of a family of relations indexed in the syntactic types of such that implies the computational adequacy property. The purpose of considering a family of relations is to provide a sufficient strengthening of the desired property to all types so that one may proceed by an inductive proof on the derivation of terms to show that holds for every term . Due to the presence of fixed-point computations, we must show that is always an admissible subset of the domain in the sense of Definition 4.12. We define a family of relations called the formal approximation relations in Fig. 5 by induction on the structure of syntactic types and show that they satisfy the properties in the preceding discussion.
Formal approximation relations may be extended to open terms as usual. We write when for all closing substitutions , we have that holds. The computational adequacy result may be deduced from the fundamental lemma:
Theorem 8.4.
For every closed term , the approximation holds.
The proof of the fundamental lemma proceeds by induction on the derivation of terms. Details and the proof that formal approximation predicates are admissible can be found in Appendix F; crucially we rely on the fact that is a -proposition.
Corollary 8.5.
Given , we have that .
Extensionally, both the denotational and computational semantics of are simply partial computations of type , so one may view Corollary 8.5 as a cost-sensitive (and internal) version of Ploktin’s original adequacy theorem for PCF. Lastly, we see that our semantics of provides a rigorous proof of the intuitive fact that computations may not observe the cost effect:
Theorem 8.6.
Any is weakly, extensionally constant in the sense that for all , if and , then and imply .
9 An SDT model of the intension-extension phase distinction
To obtain a model for the constructions of the preceding sections, we instantiate the sheaf model of Sterling and Harper [32] at the poset representing the intension-extension security order. The basic idea is to first develop domain theory internal to the presheaf topos , from which we may obtain an appropriate internal domain-theoretic site that embeds into a sheaf topos model of SDT in the sense of Definition 3.16. The reason to consider internal sites is that we may build into the base category the intension-extension phase distinction that is preserved through the embedding.
In op. cit. the internal domain theory of is developed in terms of constructive dcpos following the work de Jong [2]. These internal dcpos are similar to ordinary dcpos; for example, one may use them to give the denotational semantics of PCF [2]. The difference lies in the dominance of the category of internal dcpos given by the subobject classifier : while a partial element of ordinary domains in Set is either defined or not, a partial element of a domain internal to may have the phase proposition as its support, where is the intermediate proposition in . Recalling the interpretation of a map as a computational predicate, this also means that predicates can be phase-dependent in the sense of holding only at the extensional phase.
We recall some definitions from Sterling and Harper [32] (SH22).
Definition 9.1.
A Scott-open immersion of a dcpo is any mono arising from a predicate .
Definition 9.2.
In a category, a sink on an object is a set of morphisms into .
Definition 9.3.
In a category with pullbacks, a Cartesian coverage is an assignment of objects to set of sinks on that is stable under pullback.
Definition 9.4.
The finite open cover topology is generated by the Cartesian coverage assigning to each dcpo the set of sinks on with every a Scott-open immersion and .
Our domain-theoretic site is given by an internal category of small dcpos in . We embed into a Grothendieck topos , obtained by localizing at the finite open cover topology. The purpose of this localization is to ensure that the finite joins of the dominance in are preserved by the embedding into . This property was notably used by op. cit. to implement the semantics of termination declassification; here we use the finite join structure of to show that is an extensional predomain. The phase distinction in is inherited from the ambient presheaf topos, where it is represented by .
Theorem 9.5 (SH22, Corollary 90).
Every representable presheaf is well-complete.
Thus we obtain a functor restricting the Yoneda embedding onto sheaves.
Theorem 9.6 (SH22, B.1.4.3).
The representable is a dominance in .
Theorem 9.7 (SH22, Corollary 79).
Coproducts in are given by unions of families of Scott-opens.
Corollary 9.8.
Finite coproducts of are preserved by the embedding into sheaves.
Theorem 9.9 (SH22, Axiom-SDT-1).
The dominance has finite joins that are preserved by the inclusion .
Theorem 9.10.
Setting and , we have that is an SDT model of the intension-extension phase distinction in the sense of Definition 3.16.
Proof 9.11.
By Theorem 9.5 we know that is a well-complete dominance in . To show that also models the intension-extension phase distinction, we observe that the presheaf model of the intension-extension phase distinction of Niu et al. [18] restricts to a smaller model in : every subterminal object in is an internal dcpo, and so we may take the subterminal to be the phase proposition in . The phase proposition in is classified by : since is fully faithful, every arise from a unique map .
Moreover, we can directly verify that is internally orthogonal to in . By Corollary 9.8, preserves finite coproducts, so we have that . We observe that 2 is extensional because the restricted embedding is both full and faithful and preserves products. To see that is replete, we observe that 2 is isomorphic to its type of singletons:
Because is closed under finite joins (by Theorem 9.9), the type of singletons of 2 can be defined as the limit of a diagram of replete types, and so it is replete as well.
Lastly, to see that Phoa’s principle is satisfied, we note that it holds in . Since the subobject can be defined as the equalizer of and , every object in the diagram is defined using the cartesian closed structure of , it is preserved by any cartesian closed embedding, and so Phoa’s principle also holds in .
10 Discussion of related work
Cost analysis in type theory. The original motivation for proving internal, cost-sensitive computational adequacy results grew out of the work of Niu et al. [18] on formalizing cost analysis of functional programs in dependent type theory. Niu and Harper [17] prove such an adequacy theorem for a variant of the Algol language featuring a notion of first-order recursion in the form of while loops. The purpose of the present paper is to generalize that result to account for higher-order recursion. In contrast to both prior works, we have de-emphasized the role of the call-by-push-value language and instead work directly with the internal language of the SDT topos. Because the model we construct in Section 9 can also be seen as a model for the type theories in both prior works, we expect that it would be routine to formalize our results in a call-by-push-value version of type theory as well.
Cost-sensitive computational adequacy. The kind of cost-sensitive adequacy theorem we prove in this paper has been proved in a classic domain-theoretic setting by Kavvos et al. [13], and the general theory of computational adequacy for languages with algebraic effects has been developed by Plotkin and Power [23]. The main difference between our work and those mentioned is that we aim to prove adequacy results internally to a type theory equipped with a phase distinction (such as the one in Niu et al. [18]). As argued in Niu and Harper [17], such internal adequacy theorems can be used as a basis for the validity of axiomatic cost analysis in these type theories.
Relative sheaf models of SDT. As we have explained in Section 1.2.2, the main sheaf models of synthetic domain theory take the form of Grothendieck topoi over the category of sets. Meanwhile, the logic of phase distinctions finds its home in presheaf topoi in which one finds many distinct subterminal objects that are neither globally true nor globally false; because the category of sets is boolean and two-valued, it can have no non-trivial phase distinctions. For this reason, Sterling and Harper [32] have proposed to combine synthetic domain theory with phase distinctions by developing models in relative Grothendieck topoi [12] over a presheaf topos that exhibits a phase distinction. In other words, rather than building a site out of predomains in the category of sets, op. cit. built an internal site based on internal predomains in a category of presheaves. Our model of cost-sensitive synthetic domain theory is similar to that of Sterling and Harper [32]. On the other hand, our proof of computational adequacy is different from that of op. cit., as the latter contains a subtle error [30] involving a mismatch between the existential quantifier and the join of a family of -propositions in the lifting of free algebras to formal approximation relations.
Computational adequacy in SDT. Our approach to internal denotational semantics and computational adequacy of builds on the pioneering work of Simpson [29] on proving the computational adequacy property of PCF in elementary topoi models of SDT. One difference between our work and that of op. cit. is the addition of the phase distinction, which we use to give an intrinsic denotational account of the interaction between cost and behavior in . Another difference is in the SDT axioms used and the ensuing definition of the dynamic semantics of the object programming language. Simpson [29] assumes a property called Axiom N that closes the dominance under countable joins of decidable families in the ambient logic, a fact that we do not rely on in our constructions. The benefit of this axiom is that it enables op. cit. to give an internal definition of PCF whose dynamic semantics can be characterized by means of existentially quantified statements of the form where is a primitive recursive predicate. This is used to show that a general property of the internal logic of topoi called 1-consistency333A topos is 1-consistent when a closed formula of the form described above holding in the internal logic of implies that it holds externally. is both necessary and sufficient to externalize the internal adequacy proof into a corresponding proof in ordinary mathematics. In a follow-up paper, Simpson [28] gave a different logical criterion for the equivalence of internal and external adequacy called computational 1-consistency that does not rely on Axiom N. Roughly the idea is to define the programming language and its operational semantics in terms of the computational natural numbers (analogous to the predomain in this paper); computational 1-consistency is just the property needed to ensure that internal computational observations hold externally as well.
By contrast, the dynamic semantics of in this paper is defined computationally and is not known to be equivalent to the operational semantics of Simpson [29] in the absence of Axiom N. However, we expect that a version of our computational semantics using the computational natural numbers will be equivalent to the semantics given in Simpson [28]. On the other hand, we find the computational semantics developed in Section 7 both philosophically and mathematically compelling and deserving of further investigation in its own right. Moreover, although the computational semantics of does not appear to be definable in terms of countable joins, it can be defined using synthetic -joins of decidable families. Therefore, we conjecture that one may externalize the internal adequacy proof of in the manner of Simpson [29] by developing a Kripke-Joyal semantics for the sheaf model defined in Section 9 that unfolds an internal statement involving synthetic -joins to an external statement in the metatheory.
11 Conclusion & future work
In this paper we study a language for higher-order recursion in the setting of synthetic domain theory. Our main contribution is an internal, cost-sensitive version of Plotkin’s computational adequacy theorem for . In particular, we define and relate a denotational model of to a new dynamic semantics for defined directly in terms of computation that is both natural and mathematically appealing. Here we suggest some ideas for future investigations.
Internal vs. external adequacy. In the same vein as the work of Simpson [29, 28], we are also interested in giving a logical characterization of when internal computational adequacy (with respect to the computational semantics of ) implies external adequacy. However it is not clear to us what would be an analogous condition to 1-consistency: internal notions such as the initial lift algebra and synthetic -chains do not have natural external counterparts. As mentioned in Section 10, a first step would be to develop a systematic understanding of the logical aspects of the initial lift algebra from an external point of view.
As mentioned in Section 10, one way to obtain external adequacy would be to follow the approach of [28] and define and its computational semantics purely in terms of computational natural numbers. Alternatively, we may decide to assume Axiom N (see Section 10), which would imply that the computational semantics coincides with ordinary operational semantics in the internal logic of the SDT topos. We do not expect Axiom N to hold in the model we construct in this paper (cf. van Oosten and Simpson [34]), but it does not appear to be a limitation of the general approach to the model construction; indeed we believe it should be possible to start with a different domain-theoretic site such that the embedding into the resulting sheaf topos preserves countable coproducts, which would be enough to validate Axiom N.
Cost and information order. As discussed in Section 1.2.3, we would like to combine and develop a practical theory for the interaction of the domain-theoretic information order with a cost preorder in the sense of Grodin et al., who developed a “preorder” version of SDT in which “predomains” are types equipped with a preorder. Following the approach of relative sheaf models of SDT, we conjecture that one may build a model of SDT that further incorporates an intrinsic preorder structure by starting with a domain-theoretic site internal to the category of simplicial sets.
Recursive types. We have emphasized recursion at the term level, but synthetic domain theory is also compatible with having recursive types. Simpson [28] has developed in a very general setting the theory and existence of algebraically compact categories of predomains in SDT, and we hope to instantiate the ideas of op. cit. at a relative sheaf model of SDT similar to the one presented in this paper.
References
- [1] Beck, J., Distributive laws, in: B. Eckmann, editor, Seminar on Triples and Categorical Homology Theory, pages 119–140, Springer Berlin Heidelberg, Berlin, Heidelberg (1969), ISBN 978-3-540-36091-9.
-
[2]
de Jong, T., Domain theory in constructive and predicative univalent
foundations (2023).
https://doi.org/10.48550/ARXIV.2301.12405 - [3] Fiore, M. P., Lifting as a KZ-doctrine, in: D. Pitt, D. E. Rydeheard and P. Johnstone, editors, Category Theory and Computer Science, pages 146–158, Springer Berlin Heidelberg, Berlin, Heidelberg (1995), ISBN 978-3-540-44661-3.
-
[4]
Fiore, M. P., A. M. Pitts and S. C. Steenkamp, Quotients, inductive
types, and quotient inductive types, Logical Methods in Computer Science
Volume 18, Issue 2 (2022).
https://doi.org/10.46298/lmcs-18(2:15)2022 -
[5]
Fiore, M. P. and G. D. Plotkin, An extension of models of axiomatic
domain theory to models of synthetic domain theory, in: D. van Dalen and
M. Bezem, editors, Computer Science Logic, 10th International Workshop,
CSL ’96, Annual Conference of the EACSL, Utrecht, The Netherlands,
September 21-27, 1996, Selected Papers, volume 1258 of Lecture Notes
in Computer Science, pages 129–149, Springer (1996).
https://doi.org/10.1007/3-540-63172-0_36 -
[6]
Fiore, M. P. and G. Rosolini, The category of cpos from a synthetic
viewpoint, in: S. D. Brookes and M. W. Mislove, editors, Thirteenth
Annual Conference on Mathematical Foundations of Progamming Semantics, MFPS
1997, Carnegie Mellon University, Pittsburgh, PA, USA, March 23-26, 1997,
volume 6 of Electronic Notes in Theoretical Computer Science, pages
133–150, Elsevier (1997).
https://doi.org/10.1016/S1571-0661(05)80165-3 -
[7]
Fiore, M. P. and G. Rosolini, Two models of synthetic domain theory,
Journal of Pure and Applied Algebra 116, pages 151–162 (1997), ISSN
0022-4049.
https://doi.org/10.1016/S0022-4049(96)00164-8 -
[8]
Grodin, H., Y. Niu, J. Sterling and R. Harper, Decalf: A directed,
effectful cost-aware logical framework, Proceedings of the ACM on
Programming Languages 8 (2024).
https://doi.org/10.1145/3632852 -
[9]
Harper, R., J. C. Mitchell and E. Moggi, Higher-order modules and the
phase distinction, in: Proceedings of the 17th ACM SIGPLAN-SIGACT
Symposium on Principles of Programming Languages, pages 341–354,
Association for Computing Machinery, San Francisco, California, USA (1990),
ISBN 0-89791-343-4.
https://doi.org/10.1145/96709.96744 -
[10]
Hoffmann, J., Types with Potential: Polynomial Resource Bounds via
Automatic Amortized Analysis, Ph.D. thesis,
Ludwig-Maximilians-Universität München (2011).
https://www.cs.cmu.edu/~janh/assets/pdf/Hoffmann11.pdf - [11] Hyland, J. M. E., First steps in synthetic domain theory, in: A. Carboni, M. C. Pedicchio and G. Rosolini, editors, Category Theory, pages 131–156, Springer Berlin Heidelberg, Berlin, Heidelberg (1991), ISBN 978-3-540-46435-8.
- [12] Johnstone, P. T., Sketches of an Elephant: A Topos Theory Compendium: Volumes 1 and 2, number 43 in Oxford Logical Guides, Oxford Science Publications (2002).
-
[13]
Kavvos, G. A., E. Morehouse, D. R. Licata and N. Danner, Recurrence
extraction for functional programs through call-by-push-value, Proceedings
of the ACM on Programming Languages 4 (2019).
https://doi.org/10.1145/3371083 - [14] Levy, P. B., Call-by-Push-Value: A Functional/Imperative Synthesis, Kluwer, Semantic Structures in Computation, 2 (2003), ISBN 1-4020-1730-8.
-
[15]
LONGLEY, J. R. and A. K. SIMPSON, A uniform approach to domain theory in
realizability models, Mathematical Structures in Computer Science
7, page 469–505 (1997).
https://doi.org/10.1017/S0960129597002387 -
[16]
Matache, C., S. Moss and S. Staton, Recursion and Sequentiality in
Categories of Sheaves, in: N. Kobayashi, editor, 6th International
Conference on Formal Structures for Computation and Deduction (FSCD 2021),
volume 195 of Leibniz International Proceedings in Informatics
(LIPIcs), pages 25:1–25:22, Schloss Dagstuhl – Leibniz-Zentrum für
Informatik, Dagstuhl, Germany (2021), ISBN 978-3-95977-191-7, ISSN 1868-8969.
https://doi.org/10.4230/LIPIcs.FSCD.2021.25 -
[17]
Niu, Y. and R. Harper, A metalanguage for cost-aware denotational
semantics, in: 2023 38th Annual ACM/IEEE Symposium on Logic in
Computer Science (LICS), pages 1–14 (2023).
https://doi.org/10.1109/LICS56636.2023.10175777 -
[18]
Niu, Y., J. Sterling, H. Grodin and R. Harper, A cost-aware logical
framework, Proceedings of the ACM on Programming Languages 6
(2022). 2107.04663.
https://doi.org/10.1145/3498670 -
[19]
Paviotti, M., R. E. Møgelberg and L. Birkedal, A model of PCF in
Guarded Type Theory, Electronic Notes in Theoretical Computer Science
319, pages 333–349 (2015), ISSN 1571-0661. The 31st Conference on
the Mathematical Foundations of Programming Semantics (MFPS XXXI).
https://doi.org/10.1016/j.entcs.2015.12.020 - [20] Phoa, W., Domain Theory in Realizability Toposes, Ph.D. thesis, University of Edinburgh (1991).
-
[21]
Plotkin, G., A structural approach to operational semantics, J. Log.
Algebr. Program. 60-61, pages 17–139 (2004).
https://doi.org/10.1016/j.jlap.2004.05.001 -
[22]
Plotkin, G. D., LCF considered as a programming language, Theoretical
Computer Science 5, pages 223–255 (1977), ISSN 0304-3975.
https://doi.org/10.1016/0304-3975(77)90044-5 - [23] Plotkin, G. D. and J. Power, Notions of computation determine monads, in: Proceedings of the 5th International Conference on Foundations of Software Science and Computation Structures, pages 342–356, Springer-Verlag, Berlin, Heidelberg (2002), ISBN 3-540-43366-X.
- [24] Reus, B., Program Verification in Synthetic Domain Theory, Ph.D. thesis, Ludwig-Maximilians-Universität München, München (1995).
-
[25]
Reus, B. and T. Streicher, General synthetic domain theory — a logical
approach, Mathematical Structures in Computer Science 9, pages
177–223 (1999).
https://doi.org/10.1017/S096012959900273X -
[26]
Rijke, E., M. Shulman and B. Spitters, Modalities in homotopy type
theory, Logical Methods in Computer Science 16 (2020).
https://doi.org/10.23638/LMCS-16(1:2)2020 - [27] Rosolini, G., Continuity and effectiveness in topoi, Ph.D. thesis, University of Oxford (1986).
-
[28]
Simpson, A., Computational adequacy for recursive types in models of
intuitionistic set theory, Annals of Pure and Applied Logic 130,
pages 207–275 (2004), ISSN 0168-0072. Papers presented at the 2002 IEEE
Symposium on Logic in Computer Science (LICS).
https://doi.org/10.1016/j.apal.2003.12.005 -
[29]
Simpson, A. K., Computational Adequacy in an Elementary Topos,
in: G. Gottlob, E. Grandjean and K. Seyr, editors, Computer Science
Logic, Lecture Notes in Computer Science, pages 323–342,
Springer, Berlin, Heidelberg (1999), ISBN 978-3-540-48855-2.
https://doi.org/10.1007/10703163_22 -
[30]
Sterling, J., Erratum: adequacy of Sheaf semantics of
noninterference (2023).
http://www.jonmsterling.com/jms-005Z.xml -
[31]
Sterling, J. and R. Harper, Logical relations as types: Proof-relevant
parametricity for program modules, Journal of the ACM 68 (2021),
ISSN 0004-5411. 2010.08599.
https://doi.org/10.1145/3474834 -
[32]
Sterling, J. and R. Harper, Sheaf semantics of termination-insensitive
noninterference, in: A. P. Felty, editor, 7th International Conference
on Formal Structures for Computation and Deduction (FSCD 2022), volume 228
of Leibniz International Proceedings in Informatics (LIPIcs), pages
5:1–5:19, Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl,
Germany (2022), ISBN 978-3-95977-233-4, ISSN 1868-8969. 2204.09421.
https://doi.org/10.4230/LIPIcs.FSCD.2022.5 -
[33]
Taylor, P., The fixed point property in synthetic domain theory, in:
[1991] Proceedings Sixth Annual IEEE Symposium on Logic in Computer
Science, pages 152–160 (1991).
https://doi.org/10.1109/LICS.1991.151640 -
[34]
van Oosten, J. and A. K. Simpson, Axioms and (counter)examples in
synthetic domain theory, Annals of Pure and Applied Logic 104,
pages 233–278 (2000), ISSN 0168-0072.
https://doi.org/10.1016/S0168-0072(00)00014-2
Appendix A Properties of the dominance
See 3.12
Proof A.1.
We need to show that the intrinsic order on coincides with the path relation. First, we observe that ; indeed, fixing a map , by Phoa’s principle, evaluation at boundary obtains a pair such that implies . In one direction, suppose , which means we have a path whose boundary is determined by . Fixing , we want to show that . But this follows by evaluating at the -predicate . Conversely, if , then we have in particular , which by Phoa’s principle uniquely determines a path .
Appendix B Properties of predomains
See 4.1
Proof B.1.
Replete types are both complete and boundary separated because the latter can be defined by orthogonality conditions and is satisfied by : it is complete by the axioms of SDT (Definition 3.16) and it is boundary separated by Proposition 3.15. Assuming Phoa’s principle, the proof that replete types are linked can be found in Taylor [33, Corollary 2.10] and Reus [24, Corollary 6.1.16]. Lastly, one can show that the objects whose link relation is antisymmetric can be defined as an orthogonality condition, thus we know that the link relation on every replete type is antisymmetric, hence it follows the intrinsic order on replete types are also partial orders since they are linked.
See 4.6
Proof B.2.
We observe that is defined as the pushout of the projections of as indicated below:
Using the fact that has -equality, we obtain a map such that and . The desired characteristic map can then be defined as , where is defined as follows:
For any , if for some , then we have . Otherwise, we have that or is , which means holds and so as well. Conversely, suppose , and that and , which means that holds. If holds, we are done as in this case. Otherwise, we have , and so . Lastly, if either or is the unique element then we may discharge the case as above.
See 4.7
Proof B.3.
This is Proposition 5.4.4 of Phoa [20]. We just show the case for the function types. Given a path , it is clear that we may construct a path for all . Conversely, suppose we are given a path for all . By Proposition 4.1, is boundary separated, and so such paths are necessarily unique, and so we have a function such that is a path . We then obtain a path by taking the exponential transpose of .
See 4.8
Proof B.4.
In the forward direction, we have a path , which means implies as the is linked by Proposition 3.12. Suppose , and let be arbitrary. By assumption, we have that , where . In other words, we have implies . Since holds, we have that , which by definition means .
In the backward direction, let be the given partial path. We may define a total path between and by setting . Thus we have as required.
See 4.9
Proof B.5.
The final -coalgebra is equipped with a global element that can be thought of as the “point at infinity”. Define be the element determined by the unique extension evaluated at the invariant point .
-
\normalshape(1)
First we show that is an upper bound for . Fixing , we need to show that . Because extends , it suffices to show . Using the fact that every map is monotone with respect to the specialization order, the result holds because .
-
\normalshape(2)
Let be an upper bound for . We need to show that . If the principal lower set is complete, we have the following lifting situation:
In the above is the unique extension of considered as a map . By uniqueness of as the extension of , is equal to considered as maps . Consequently we have that , so the result follows by observing that .
It remains to show that is complete. We can express the principal lower set as follows:
Because complete types are internally complete, the result would follow if we can show that is complete. We may show that can be computed as follows:
Since can be defined as the limit of a diagram of complete types, it is complete as well.
See 4.14
Proof B.6.
Given , we derive a path whose boundary is by postcomposing with , and so as well.
See 4.15
Proof B.7.
Predomains are complete, so we have the following extensions of and :
Because extensions along are unique for complete types, we have . But by definition of the synthetic -join, this means that .
Proposition B.8.
The intersection of a family of admissible subsets of a domain is admissible.
Proof B.9.
The least element is contained in the intersection as it is contained in every fiber. Suppose that is a synthetic -chain such that . But since for every , we have as every is admissible, which means as well.
Proposition B.10.
If are -subsets of a domain , then the exponential subobject is an admissible subset of .
Proof B.11.
Let for some synthetic -chain . Suppose that . We need to show that . By the universal property of , we may assume that for some . By assumption, this means that and thence as every -subset is monotone in the synthetic order.
Appendix C Properties of the denotational semantics
See 6.1
Proof C.1.
Routine computation using the distributive law of over the lifting monad.
Appendix D Properties of the computational semantics
See 7.1
Proof D.1.
Consider the following subset:
We may check that is admissible and proceed by fixed-point induction. Suppose that and that and . We need to show that . We proceed by cases on .
-
\normalshape(1)
If , we may deduce that and , so the result follows from the assumption that .
-
\normalshape(2)
Otherwise, we have that and by definition of , and so .
See 7.2
Proof D.2.
Consider the following subset of :
It suffices to show that . Observing that is admissible, we proceed by fixed-point induction. Suppose that , , and that . We need to show that . We proceed by cases on .
-
\normalshape(1)
If , then we compute:
Where the first equality follows from the assumption that and the second by the definition of .
-
\normalshape(2)
Otherwise, we have that . Since holds, we can compute:
But this is what we needed to show since .
See 7.4
Proof D.3.
Consider the subset defined as the intersection of the following subsets:
It suffices to show that . We have that is admissible, and we proceed by fixed-point induction. Suppose that . We need to show that , where is the characteristic functional of (Section 7.1). It’s immediate that . It remains to show that it is also contained in . So suppose that and . We want to show that . We proceed by cases on .
-
\normalshape(1)
If , then we know that for some . Stepping the operational semantics, we have that , and by definition of the computational semantics . Since we assumed , we also have , and since is discrete we have . Recalling the premise and the fact that , we may conclude that , which is what we needed to show.
-
\normalshape(2)
Otherwise, for some , and we have that . By definition of the computational semantics, this means that . Since we assumed that , we can use the laws of the derived algebra (Proposition 6.1) to deduce that as well, and so by the assumption that , we have that holds, which is what we needed to show.
See 7.5
Proof D.4.
In one direction, we show that implies and both denote identical costs. Consider the -predicate such that if and only if . Suppose that and . By computational induction on sequencing Proposition 7.4, it suffices to show that . Applying computational induction on , we further suppose that and and aim to show that .
-
\normalshape(1)
We claim that . By the big-step semantics of profiling Corollary 7.3, it suffices to show that for some and . The former follows from our assumption; for the latter, it suffices to show that and , both of which follow from assumptions.
-
\normalshape(2)
Given that , we may apply computational induction again: supposing that and , we have to show that , which follows from the uniqueness of evaluation Proposition 7.1 and big-step semantics of profiling Corollary 7.3.
In the other direction, suppose that . It suffices to show that . By computational induction, we may assume that and . Applying computational induction again, we can also assume that and for some . By the big-step semantics of profiling Corollary 7.3, it suffices to show that and . The latter is our assumption, and the former follows from the big-step semantics of evaluation Proposition 7.2.
Proposition D.5.
The following is valid: {mathpar} \inferrule (f, λe) ∧(e[v], (w)) →φ((f, λe) + (e[v], (w))) (f v, (w)) →φ((f v, (w)))
Proposition D.6.
We have that .
Appendix E Soundness of the denotational semantics
See 8.1
Proof E.1.
By induction on the derivation of .
See 8.2
Proof E.2.
Consider the following subset:
Because is a -proposition, we see that is an admissible subset. Suppose that and . We need to show that . We proceed by cases on .
-
\normalshape(1)
If , then by the soundness of the one step relation Proposition 8.1, it suffices to show that , which follows from the assumption, noting that implies .
-
\normalshape(2)
Otherwise, we have that , and so the result holds since .
Appendix F Proofs for the computational adequacy property
Proposition F.1.
If and , then .
Proof F.2.
By induction on , using the laws of the cost algebraProposition 6.1.
F.1 Admissibility
Proposition F.3.
We have that is an admissible subset of .
Proof F.4.
First, we have to show that . By definition, this means to show for all . But this holds since and is the least element of . Otherwise, let be a synthetic -chain such that for all . We want to show that , which is to show that for all . Since , this means to show . By the universal property of the synthetic -supremum, it suffices to show for all , but this is the assumption.
Proposition F.5.
Suprema of synthetic -chains in function spaces are computed pointwise.
Proposition F.6.
Given that is admissible for all , we have that is as well.
Proof F.7.
Because , we have that . Suppose that . We need to show that . Suppose that . We need to show that . This follows from the characterization of synthetic -suprema in function spaces (Proposition F.5) and the assumption that .
Proposition F.8.
Given , we have that is an admissible subset of .
Proof F.9.
By Propositions F.3 and F.6.
F.2 Fundamental lemma
We give the representative cases of the proof by induction on the derivation of terms.
Lemma F.10.
If , then .
Proof F.11.
Let . We need to show that . Computing the denotational semantics and applying Proposition F.1, it suffices to show that , which follows from our assumption.
Lemma F.12.
If and , then .
Proof F.13.
By induction on .
-
\normalshape(1)
If , let . We need to show that . Computing the denotational semantics and using the fact that we may reassociate sequences (Proposition 7.5), it suffices to show . By the assumption that , it suffices to show that for all , we have that , which follows directly from the assumptions that and .
-
\normalshape(2)
If , suppose that . We need to show that . Unraveling the denotational semantics and the computational semantics (using Proposition D.6), it suffices to show , which follows from the inductive hypothesis and the assumption that .
Lemma F.14.
If , then .
Proof F.15.
Since , the result holds by Proposition F.1.
See 8.4
Proof F.16.
By Lemmas F.10, F.12, F.14 and F.8.
See 8.6
Proof F.17.
Let and be the costs denoted by and . By soundness Theorem 8.2 and laws of the derived algebra Proposition 6.1, we have that and similarly . It suffices to show that . Because 2 is a purely extensional type (as required by Definition 3.16), we may assume that holds. By assumption and soundness, we have , and so , which means that since as elements of a purely intensional type .