Structural semantics for polymorphic data types (preliminary report)
Authors: Daniel Leivant
Venue: Proceedings of the 10th ACM SIGACT-SIGPLAN symposium on Principles of programming languages (1983)

The semantic modeling of data types has been the subject of increased interest over the last few years, enhanced by the development of applicative languages such as Edinburgh's ML and HOPE, by the need for flexible highly structured languages that would nonetheless be amenable to verification, and by ongoing inquiries on polymorphism in programming languages. In particular, there has been a growing interest in generic type structures such as the Reynolds-Girard discipline of full polymorphism, further extended by McCracken [McC] and MacQueen and Sethi [MS], and in user-defined and recursively-defined types. Our aim here is to model semantically the notion of type so as to encompass full polymorphism, but in a very controlled way which on the one hand allows the modeling to remain simple, and on the other hand conveys as much of the notion of type as seems feasibly relevant to programming languages. Our leading idea is that a type is a structural condition on data objects rather than a collection of objects which satisfies certain closure properties. Roughly, we argue that such structural conditions are fully conveyed by syntactic expressions, not in isolation of course, but within a syntax-oriented type discipline. In other words, we treat types as discrete objects, which merely code the ways data objects are allowed to interact (as in applying functional object a to object b). Once a type discipline is set to delineate a set of type expressions, and once the meaning of the type-constructs is imposed on the ways the data objects relate, the meaning of each type expression is conveyed by the expression itself (reduced to a canonical form if necessary). This conception of types permits a strikingly simple modeling of the use of types as arguments of data objects, a use central to Reynolds' polymorphic type system [Rey]. The use of types as genuine arguments of procedures is not devoid of practical interest. E.g., one may wish to treat objects of type &ocirc; generically, except for an initial choice depending on the principal type-constructor of &ocirc;, that is, according to whether &ocirc; is an atomic type, a functional type, a cartesian product, etc. A particular situation where such choices may be useful is where a procedure has a formal parameter intended to range over some data structure (trees of sequences of objects of type t, say), a data structure that has a number of accepted representations by formal data types. It seems desirable to permit the definition of a polymorphic procedure that would accept as valid a number of such formal representations, branching on them internally. This kind of facility would elevate the polymorphism of a procedure from the level of uses with in a single program, to the level of transportability from one set of data structure specifications to another. This kind of use of types as arguments is compatible with Reynold's discipline of type abstraction, but not with the quantificational discipline of [MS] (cf.[Lei83], &sect;4.2). While the two disciplines, as uninterpreted and unexpanded calculi, are combinatorially isomorphic the difference between their intended semantics becomes apparent when primitive functions over types (such as discriminators over main type-constructor) are considered. The examples we have given of uses of types as arguments are fairly restricted in nature: all that is used of a type is its syntactically representable structure. This is not merely an empirical observation on our limited perception at present time. In a typed discipline of programming each object carries its type (explicitly or not), and all types of denotable objects are themselves denotable. It follows that any question that one may ask about the type of a denotable object reduces to a question about type-expression(s) denoting that type. The issue of semantically modeling Reynold's rich discipline of type abstraction is therefore reduced, from a pragmatic point of view, to a modeling in which questions about types are all expressible as questions about type expressions. Existing approaches to the semantic modeling of data types are, in one form or another, conceptual continuations of the denotational semantics approach to data objects. McCracken [McC], following [Sco], defines types as retracts of the universal domain. In Shamir and Wadge [SW], Milner [Mil] and MacQueen and Sethi [MS] types are modeled as some kind of ideal, where an ideal is a subset of the object-domain that satisfies certain closure conditions. In both approaches types are being defined via the properties that they must satisfy, as sets of objects, so as to become compatible with their use. (This may be compared with the algebraic approach to types, where each particular type is defined via its algebraic properties rather than its intended conception). Our modeling of types too is grafted on top of a denotational semantics for the object language, However,it has a life of its own, and can be explained in isolation, or combined with for instance, an operational semantics for the object language. The point we are trying to make is that the semantics of types has little to do with the issues of self-application and continuity which motivate denotational semantics. Rather than amalgamate objects and types, as in [SW] (where types as sets of objects are treated on an equal footing with objects as sets of approximations), we separate the two radically. We make no claim, of course, that our approach should supplant the modeling of types as retracts or as ideals. Rather, we believe that the semantics we propose is related to types-as-ideals in much the same way as operational semantics is related to denotational semantics: it is closer to programming practice, permits a smaller set of objects, and is sensitive to the choice of formal framework (which for us is the type discipline). We therefore feel that the two approaches should shed light on each other and, in combination, enhance our understanding of complex data-types and and their proper use. In particular, we believe that even putting down the definitions and proving basic existence theorems provides some insight about the design and use of data types. For one, our modeling of types suggests a feasible controlled use of types as arguments of data objects. For another, it points to directions in setting very rich type disciplines evolving naturally from a structural-computational view of types. For instance, it may be useful and feasible to consider types built as certain recursive sets of other types. Following preliminaries in sections 1 and 2 we define in section 3 what is a model of the pure polymorphic lambda calculus.A term model is constructed in &sect;4,in &sect;5 we show how to construct a non-extensional model through the solution of a domain equation, and in &sect;6 we construct an extensional model through such a solution. The latter construction involves breaking the circularity in the conditions underlying polymorphic typing, by a method akin to Girard's in the proof theory of higher order logic [Gir]. We plan to extend this work in two directions. One is the treatment of more general type disciplines, of the kinds defined by McCracken [McC] and further studied by MacQueen and Sethi [MS]. The crucial issue here is that, in contrast to Reynold's discipline, distinct type expressions may denote the same type. However, each type expression has a normal form, which may be viewed as its "value" (this view has been advocated in greater generality by Per Martin-Lof [Mar], on somewhat more philosophical grounds). A second direction, incorporating aspects of the first, is the treatment of recursively defined data types in a polymorphic context, and possibly more general notions of types.