Fundamenta Informaticae 30 (1997) 23{41 IOS Press
1
A Convex Powerdomain over Lattices: its Logic and -Calculus Fabio Alessi
Dipartimento di Matematica e Informatica Universita di Udine via delle Scienze 208, 33100 - Udine, ITALY email:
[email protected]
Mariangiola Dezani-Ciancaglini, Ugo de' Liguoro
Dipartimento di Informatica Universita di Torino corso Svizzera 185, 10149 - Torino, ITALY email:dezani,
[email protected]
Abstract. To model at the same time parallel and nondeterministic functional calculi we de ne a powerdomain functor P such that it is an endofunctor over the category of algebraic lattices. P is locally continuous and we study the initial solution D1 of the domain equation D = P ([D ! D]? ). We derive from the algebras of P the logic of D1 , that is the axiomatic description of its compact elements. We then de ne a -calculus and a type assignment system using the logic of D1 as the related type theory. We prove that the lter model of this calculus, which is isomorphic to D1 , is fully abstract with respect to the observational Preorder of the -calculus. Keywords: -calculus, Nondeterminism, Full Abstraction, Powerdomain Construction, Intersection Type Disciplines.
1. Introduction One of the main issues in the design of programming languages is the achievement of a good compromise between the multiplicity of control structures and data types and the unicity of the mathematical semantics. This is especially compelling when combinations of dierent features induce an intricate syntax. In particular the development of functional languages endowed with primitives for parallelism and concurrency, like Concurrent Clean [33], CML [36] and FACILE [16, 17], calls for a mathematical treatment of functions and their extensions to \sets" of values (for a survey about the subject see e.g. [39]). The aim is to give a semantics more abstract than term models, and logical principles to reason about programs. When dealing with these problems, it is usual to start with a calculus, and then to discover an abstract model explaining the underlying mathematical ideas. We go in the opposite direction: given a dicult problem, such as assessing in the same language call-by-name and call-by-value functional abstraction, nondeterministic and parallel evaluation, we concentrate on those functors over domains that seem to be good candidates for a mathematical
2
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
formalizations of these notions. In this perspective the desired \combination" is realized by functorial composition in a system of domain equations. Provided that the system has a solution, this determines both a domain of interpretation and, what is more relevant, the guidelines of the de nition of the syntax. In the present paper we address the question of combining functionality, nondeterminism and parallelism. In [11] and [14, 15] the problem was solved using domains which were algebraic lattices, but this prevents from the use of the convex powerdomain [35], as the category of algebraic lattices is not closed under that functor. A nondeterministic -calculus modeled by convex powerdomain in the category of SFP has been studied by Ong [32], but it remains unclear how to model parallelism in that setting. In the present paper we propose a solution based on a new powerdomain functor. This functor is close to Plotkin's convex powerdomain functor, but it works within the category of algebraic lattices, so that parallelism can be understood as a join operator. An extended abstract of the present paper appeared as [5].
1.1. Powerdomains in the category of algebraic lattices Set theoretically a many-valued function is a function with values in some powerset. If one takes domains and continuous functions as abstract counterparts of data types and computable functions, the problem of a theory of many-valued functions reduces to the problem of a theory of powerdomains. Dierent constructions are possible, essentially because of different treatments of the unde ned object. In the theory of powerdomains (see [35, 40, 24] and [20] for an elementary presentation) three main constructions have been devised (for other constructions, see e.g. [18, 19, 21]): the lower, upper and convex powerdomains. Roughly speaking, the lower powerdomain identi es those sets which have the same de ned objects, while the upper powerdomain identi es with the totally unde ned set any set having the unde ned object among its elements. The convex powerdomain has a ner order on sets, which is obtained by combining those of both lower and upper powerdomains. A consequence is that the presence of the unde ned object within a set is neither ignored nor collapsing the set to the unde ned object itself. It could be asked, however, what are the right powerdomains to model parallelism and nondeterminism respectively. There is a general agreement in considering the parallel composition of two functions as the best behaved among them with respect to the partial ordering of their ranges. In case of functions this leads to the interpretation of the parallel operator as a join: in case of many-valued functions the lower powerdomain is the right choice. These two things match in the case of prime algebraic lattices: indeed any such structure is isomorphic to the lower powerdomain of its compact coprime elements; therefore the continuous union operation of the powerdomain coincides with the join. This reinforces the intuition that lower powerdomain and lattices are natural models for such \parallel functions" (see e.g. [11] for an application to parallel extensions of both the lazy, call-by-name and call-by-value -calculus). Things are less clear when modeling nondeterminism. In this case, if we want to keep it distinct from parallelism (see [27] for some reasons to do this), we are left either with a theory of total sets (i.e. not including ?) based on the upper powerdomain (for which see [14, 15]), or with some theory of partial sets. Unfortunately the category ALG of algebraic lattices is not closed under the convex powerdomain, which is a serious drawback if we wish to model by partial sets a calculus in which both nondeterminism and parallelism are present (like in [31, 14]). To solve this problem we introduce a new powerdomain functor P such that the category of algebraic lattices is closed under P . Let D be an algebraic lattice; following a general pattern, we consider the set M (D) of nite non-empty sets of compacts in D, and de ne a
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
preorder over this set by u v , [8e 2 v 9d 2 u: d v e] & F u v F v;
3
(1)
By contrast we recall the de nition of the preorder on M (D) inducing the convex (or Plotkin) powerdomain:
u vEM v , [8e 2 v 9d 2 u: d v e] & [8d 2 u 9e 2 v: d v e] Clause 8e 2 v 9d 2 u: d v e is the same in both de nitions, and it isFexactly the de nition F of Smyth preorder, inducing the upper powerdomain. Clause u v v in the de nition of is weaker than [8d 2 u 9e 2 v: d v e]: actually the latter implies the former. In this sense our powerdomain is a weakening of the convex powerdomain, retaining, however, the property of convex sets: indeed if d1 v d2 v d3, then fd1; d2; d3g is equivalent to fd1; d3g under both preorders. The quotient of M (D) under is a sup-semilattice. It follows that, if we take P (D) as its ideal completion, then we obtain a complete lattice, which is algebraic. Singleton fj jg and union ] operations are de ned in the standard way, and the action of P over a continuous map f : D ! E of algebraic lattices is then given by the unique continuous extension of the map f y(fjd jg ] ] fjd jg) = fjf (d )jg ] ] fjf (d )jg ] fjf (F d )jg: (2) 1
n
1
n
in i
It follows that P is a functor and that P (D) is actually a free construction, and indeed it is initial in the category of P -algebras, here called oper-ALG. This consists in the subcategory of ALG, whose objects are oper-lattices (introduced in this paper), that is lattices endowed with a continuous binary operation which is idempotent, commutative and associative, and which satis es the law (d1 d2) t d3 = (d1 t d3 ) (d2 t d3): Morphisms of oper-lattices are continuous maps satisfying the law f (d1 d2) = f (d1) f (d2) f (d1 t d2):
1.2. A notion of call-by-value functions P (D) is a powerdomain of partial sets, in the sense of the discussion of the previous paragraph, and it is similar to the convex powerdomain. More precisely, the closure operator associated to P has as xed points exactly those subsets of D which are convex (X is convex if X 3 x v y v z 2 X implies y 2 X ) and closed under arbitrary join. Let us concentrate on the set of compact elements K (P (D)) of a lattice P (D). There are three kinds of objects: the bottom element, that is ?P (D) = fj?D jg; total objects of the shape fjd1; : : : ; dnjg (an abbreviation for fjd1jg ] ] fjdn jg), where di = 6 ? for all i; nally objects of the shape fjd1; : : :; dn ; ?jg, the partial objects dierent from ?. Two main choices for the set of values are possible: either a value is any object which is dierent from ?P (D), call this set V [; or the set of values coincides with the set of total objects, call this set V ] (strictly speaking, these de nitions concern just compact values, but they uniquely extend to the whole P (D)). In order to compare these two possibilities, let us consider the spaces of call-by-value functions that they determine. First of all these have to be strict functions and, since they are de ned from powerdomains to powerdomains, they are taken as extensions of functions between domains underlying the powerdomains. More precisely, we consider functions g : P (D) ! P (E ) such that g = P (f?) for some f : D ! E . As usual, f? = d: if d = ? then ? else f (d). Thus, for instance, g(fjd; ?jg) = fjf (d); ?jg.
4
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
We now parametrize the above de nition with respect to a set V P (D) of values. If f : D ! E then it determines the call-by-value function f V : P (D) ! P (E ), relative to V : f V = s 2 P (D): if s 2 V then P (f? )(s) else ?: (3) It is easy to ]see that f [ (fjd; ?jg) = fjf (d); ?jg, while f ](fjd; ?jg) = ? (where f [ = f V [ and f ] = f V ). Moreover, if both d1 and d2 are dierent from ?, then f [(fjd1; d2jg) = fjf (d1); f (d2); f (d1 t d2)jg. In general this amounts to say that, for any s; t 2 P (D), f [(s ] t) 2 V [ , f [ (s) 2 V [ or f [(t) 2 V [ , f [(s _ t) 2 V [; where _ is the join in P (D). This implies that call-by-value functions do not discriminate the union and the join when the set of values is V [. On the other hand choosing V ] we have f ](s ] t) 2 V ] , f ](s) 2 V ] and f ](t) 2 V ] f ](s _ t) 2 V ] , f ](s) 2 V ] or f ] (t) 2 V ]: Note that, if e.g. s = fjd1; ?jg and t = fjd2; ?jg, then s _ t = fjd1; d2; d1 t d2; ?jg. Since we want to preserve the distinction between many-valued functions arising from nondeterminism and those which model parallel computations, our choice has to be V = V ].
1.3. The domain equation
We choose a type-free universe to work with. To treat functions as objects in the universe we endow the powerdomain with an applicative structure. Much like in case of models of type-free -calculus, objects are at the same time functions and elements in the domain of these functions: in the present case they should be viewed also as sets of functions. Moreover all functions are basic values (that is non-bottom elements of the domain D of which we shall take the powerdomain P (D)), hence the space of functions has to be lifted, so that even the everywhere unde ned function will be dierent from the bottom (and hence from the singleton of the bottom). This leads to the following system of domain equations: ( D = P (N? ) (4) N = [D ! D]: If we want to underline that the objects we are dealing with are \sets", then we have to solve the equation D = P ([D ! D]? ): (5) Otherwise, if the rst class objects are functions, we get N = [P (N?) ! P (N? )]: (6) Both solutions exist, and we call them D1 and N 1 respectively, since P turns out to be locally continuous, so that they can be obtained as direct limits. Considering the equation (5), application ( ) is naturally de ned (restricting ourselves again to the compact elements) as follows: 8 < f1(d) ] ] fm (d) if ff1; : : :; fm g [D ! D] fjf1; : : :; fmjg d = : f1(d) ] ] fm?1 (d) ] ? if ff1; : : :; fm?1 g [D ! D] and fm = ?. (7) On the other hand, if we consider (6), we have a particular case of the construction in [29]. Indeed it turns out that the functor T = P ( )? is a strong monad, and that the solution N 1 is a call-by-name T -re exive object. Following [29], we can de ne an application morphism which, up to the usual identi cation of an element d of D1 = T (N 1) with the corresponding \point" d : 1 ! T (N 1) (where 1 is the terminal object in the category), turns out to coincide with ( ).
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
5
1.4. Representation of D1
Working inside the category of algebraic lattices, with Scott continuous functions as morphisms, has also the technical advantage that the domain can be described using the theory of Extended Abstract Type Structures (see [12]): this is simpler than the theory of Domain Prelocales (see [2]) which is used for describing SFP domains. EATS are isomorphic to the (dual of the) join-semilattice of compact elements of !-algebraic lattices. A minimal EATS is generated from a countable set of type constants closed under a binary operator ^. Types are taken with a preorder such that, taking the quotient, ^ is the meet of and . Given an EATS, the whole domain is recovered from lters of types, ordered by subset inclusion. EATS's are instances of Information Systems (see [37]), and represent several domain constructors. As usual, intersection represents join: no compatibility restriction is required since we work with lattices (for more details see [13]). The constructors involved in equation (5) are lifting, exponentiation and the powerdomain functor P . The lifting is easily represented by adding a constant ! as the top, so that the lter " ! will be the newly added bottom of the domain of lters. The space of continuous functions is represented by arrow types ! . The axioms concerning the arrow are the usual contravariance-covariance law plus ( ! ) ^ ( ! ) ! ^ ! ! ! ! !: The former is needed to have a unique representation of step functions via principal lters of arrow types. The latter implies that the set of arrow types has a maximum, namely ! ! !, so that, dually, the function space has a minimum: x: ?. It is then clear why we have to rule out the inequation ! ! ! ! (which is on the contrary included e.g. in [9]), since this would collapse the bottom of the space [D ! D] with the bottom of [D ! D]? . We are left with the functor P . The compact elements of P ([D ! D]? ) can be identi ed with the set M (P ([D ! D]? )), therefore we need a type connective which is the EATS counter-part of the union. To this aim we introduce a binary operator , and the axioms involving follow directly from the de nition and properties of . is idempotent, commutative, associative and distributes over meet. This, together with the covariance of in both its arguments, implies that the following equation holds: = ( ^ ); which represents the property that \sets" in our powerdomain are closed under joins of their elements. We just remark that no special constructor is needed for the singleton operation, since all \singletons" will be represented exactly by those types that cannot be non-trivially equated to any type whose outermost operator is . We can now face the problem of representing the initial solution of equation (5). Indeed, applying to the case of EATS the technique to solve domain equations using Information Systems (see [26]), we know that it suces, for each domain Dn in the direct limit D1 = lim Dn (that gives the solution of (5)), to put into a single bag the types that represent its compacts, and then to take the space of lters. Now D0 is the one element domain, hence no basic type constant but the constant ! is needed, and the representation of the domain D1 will simply be the set F of all lters of types generated from ! closing under ^, ! and , which are (pre)ordered as described above.
1.5. A -calculus of call-by-name and call-by-value many-valued functions
Usually one begins with a syntax, that is a language and a notion of evaluation, and looks for a model and an interpretation equating equivalent terms. In our exposition we go in the opposite direction. First an abstract structure of objects has been devised, and then
6
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
we look for a syntax which is expressive with respect to that structure. The criterion of expressibility, as we shall see in the next sections, is adequacy and completeness, i.e. full abstraction. To x ideas, we start with the syntax of type free -calculus. We have to de ne both callby-name and call-by-value abstractions, and we choose to introduce two sorts of variables, namely x; y : : : and v; w; : : : so that x:M and v:M are call-by-name and call-by-value abstractions, respectively. Then we enrich this syntax (see e.g. [31, 14]) by adding binary operators for set construction (implicitly representing the nondeterministic internal choice) and parallel evaluation: \+" and \k", respectively. The intended interpretations of these operators are the powerdomain union and the join of the lattice. Turning to the reduction relation, usually written ?!, we consider rules ( ), () and ( ) from the classical -calculus (see [8]), but not rule (). This last rule allows to reduce under -abstractions. Now a -abstraction always denotes a function (to be identi ed with the singleton of that function), then a total object, that is an element of V , so that it doesn't make sense to evaluate further its body (see [34]). To cope with commutativity, associativity and idempotency of + and k we introduce a congruence relation such that e.g. M + N N + M , and then we put M M 0; M 0 ?! N 0; N 0 N ) M ?! N: (8) Beside that, the reduction rules for + and k will be the same: rst if M ?! M 0, then both M + N ?! M 0 + N and M kN ?! M 0kN . Second, since anything can be applied to anything else, we have to add rules for reducing an application where the leftmost term is either a sum or a parallel composition. These are (M + N )L ?! (ML) + (NL) and (M kN )L ?! (ML)k(NL): To understand these rules one may think, for the leftmost one, of the semantic de nition of application (7). The rightmost one is explained by the fact that the ordering of the function space is the pointwise ordering, so that the join of two functions f and g is the map x: f (x) t g(x). We account for the distributivity of the join over the union in the domain D by adding the rule (M + N )kL ?! (M kL) + (N kL): (9) Although union also distributes over join, we do not have the rule (M kN ) + L ?! (M + L)k(N + L); (10) essentially because, as it will appear clear, the calculus requires to bubble sums, and not to nest them. The point of having the same operational semantics for both + and k is that, as it is the case for denotational semantics, we expect that they are discriminated by call-by-value functions. It is then crucial to give the de nition of the set V of syntactical values and the corresponding rule of call-by-value -contraction. The following grammar for the set V of syntactical values is justi ed thinking to the set V of semantical values: V ::= v j x:M j v:M j V + V j V kM j M kV: (11) Indeed a call-by-value variable is meant to be interpreted into (a subset of) V , hence it is a syntactical value. Abstractions, both call-by-name and call-by-value, are objects in [D ! D], and therefore, as elements of D, singletons of non-bottom elements. If V1 and V2 are values, hence sets of non-bottom elements, their union is such, therefore V1 + V2 is a value. Finally, it is not dicult to show that V is an upper-closed set, hence V kM and M kV are values for
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
7
any M . Any other term, that is something of the shape MN or of the shape M + N and M kN but not generated by the grammar (11), is not immediately recognizable as a value (even if it will possibly reduce to a value). We come to the de nition of the call-by-value contraction. This rule usually takes the form (v:M )V ?! M [V=v] if V 2 V: (12) In view of (3), however, this rule is sound just in case V is a syntactical value that denotes a singleton. Indeed, if V has the shape V1 + + Vn (where, say, each Vi is a singleton value), then (3) and (2) show that the eect of reducing (v:M )V should be the following. First compute the \distribution" of the function denoted by v:M over the elements of the \set" V , including their join: (v:M )(V1 + + Vn ) ?! (v:M )V1 + + (v:M )Vn + (v:M )(V1k kVn ) (13) and then apply (12). To realize this, it is essential to discriminate among values in general and singleton values. Tentatively one just drops V + V from (11). Unfortunately this is not enough. Consider the term (M + N )kV , where V represents a singleton. By (9) this evaluates to (M kV )+(N kV ), which doesn't denote a singleton in general. Clearly we require that, whenever V ?! V 0, 0 (v:M )V and (v:M )V are semantically equivalent (for now: denote the same object). Even worse, we have to consider the term LkV , where L is not a sum itself, but just reduces to a sum: something which cannot be eectively foretold. This says that we cannot have a simple syntactical de nition (like a grammar) which discriminates between terms denoting singletons and terms denoting sets of more than one element. In order to approximate the solution we observe that this problem is similar to the general one of recognizing whether a term denotes a value or not in the classical call-by-value calculus (see [34]). In that case to evaluate (v:M )N one reduces N until (eventually) a value is obtained, and then the contraction takes place. Here we do the same until a value is reached from N (if any), but then we have to distinguish among several cases. If V is a closed term in the subset W of V generated by the grammar W ::= v j x:M j v:M j W kW (14) then rule (12) can be safely applied, since V surely denotes a singleton value. We observe that in such a case V can never reduce to a sum. If V is in the subset U of V generated by the grammar U ::= W j U kM j M kU (15) but V 62 W, then V is not a normal form, even if it is always equivalent via to a term of the shape W kN . For a similar notion of value which is reducible see [11, 14]. In this case we cannot simply substitute V for v in M as in (12), since V could evaluate to a sum. Indeed, if V 2 U n W, then V W kN for some W 2 W and N 62 U. It is clear that W is not guaranteed to be the \best" among W and N , since N could evaluate to something which is better behaved than W , at least in some contexts. Therefore we replace v by W and we put the result in parallel with (v:M )V 0, where V 0 is obtained from V by one step of reduction. (v:M )V ?! M [W=v]k(v:M )V 0 if V W kN & W 2 W & N 62 U & V ?! V 0: (16) Finally, if V 2 V n U (in such a case it is a proper sum), then rule (13) applies.
1.6. The convergence predicate and the observational preorder
To compare the operational semantics with the denotational semantics and hence to check whether the expressibility criterion has been satis ed or not, we introduce a (pre)-congruence
8
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
among terms which is based on the notion of convergence that the previous de nition of ?! naturally induces. Let the predicate M +must , to be read as \M must converge", be de ned as follows: V: M +must , 9V 2 V: M ?! (17) At rst sight this looks like a may convergence predicate. Indeed \must converge" should be reserved to those terms such that any reduction out of them produces a value. Indeed, a notion of must convergence de ned by considering all possible reductions of a term is problematic, since, as it will be shown in Remark 4.2, the reduction relation informally presented in the above subsection is not Church-Rosser. However there are two relevant facts: rst we shall prove that, if M +must and M ?! N , then N +must , which is a strong property especially because of lack of con uence. Second our values are sets, representing all possible outputs of a nondeterministic computation; but they are also, as values, total objects, hence the convergence notion that they induce is a must convergence predicate. At the same time we introduce a may convergence predicate, which is motivated by the possible choice of V [ as the set of values. Its de nition is (without changing the de nition of syntactical values) V + N: M +may , 9V 2 V; N: M ?! Note that if M +must then M +may : indeed if M ?! V for some V 2 V, then, by (8), it is also the case that M ?! V + V . Any convergence predicate + induces a theory which is a Morris theory (see [30]). The theory is the set of the following inequations: M vO N , 8 context C [ ] closing both M; N: C [M ] + ) C [N ] + : (18) Otherwise stated it is the theory of the observational preorder where the only observable is convergence (see [3] and a long sequence of papers thereafter). We shall study the theory induced by the predicate +must for the same reason we chose V ] instead of V [ as our semantical notion of value. Indeed with the second choice union and join collapse; similarly, choosing +may as our convergence predicate, + and k collapse.
1.7. The type assignment system and full abstraction theorem Let [ ] : Env +k ! D1 be the interpretation map formalizing the denotation of terms as
informally described in the previous paragraphs. The statement assuring that the calculus correctly describes the structure D1 is: M vO N , 8 2 Env: [ M ] v [ N ] : To establish this equivalence we use a standard methodology. We introduce a formal system assigning types to terms, starting from type assignments for (term) variables. The judgments of this system are of the shape ? ` M : ; where ? is a mapping of variables into the set of types and it is called the \basis" of the judgment. Deduction rules in the system will describe the structure of types according to the structure of terms, with three relevant exceptions: ? ` M : ? ` M : . (!) ? ` M : ! () ? ` M : ( ^ I) ?`M : ?`M :^ These rules ensure that the set of types that can be given to any term M is a lter. Now the map [ ] induces an interpretation [ ] F sending terms into F via the isomorphism between D1 and F . Then we prove that [ M ] F = f j 9?: ? j= & ? ` M : g;
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
9
where associates to each variable a lter, and ? j= is true if and only if ?() 2 () for all (term) variable . This theorem says that types characterize the denotations of terms. The next step is to show that types characterize the operational behaviors of terms. This is accomplished rst by showing that types are preserved by conversion (namely by the re exive, symmetric and transitive closure of ?!), denoted by = : ? ` M : and M = N ) ? ` N : : Further we prove that types characterize the convergence of (closed) terms, that is M +must , ` M : ! ! ! and M +may , ` M : (! ! !) !: Finally we have to show that the calculus is able to check internally the typeability of a term M by a type . This can be obtained by nding terms and such that ` : , and M +must , ` M : : Intuitively, and represent respectively the \worst" term that has the type and the \test" term which, when applied, checks whether its argument has type . and will be de ned by mutual induction. It is at this point that one realizes that something is missing in the calculus, namely the de nability of the join of the elements of a set, which is essential to test if a sum M + N has a type exactly when either the rst one has type and the second or viceversa. Therefore we introduce in the syntax of the calculus an unary operator ` whose semantics is a G (fjd1; : : :; dm jg) = fj dijg; R
R
R
T
T
T
R
T
im
and we add to the de nition of ?! suitable rules dealing with this operator.
2. The Powerdomain Construction In order to meet the requirements illustrated in the introduction, we construct a new powerdomain functor, based on a preorder which coincides with Egli-Milner preorder on those ( nite) sets which contain a maximum. Next we study the solution of a domain equation which yields an applicative structure in which objects are \sets" of functions from objects to objects. We recall some standard de nitions andFnotions. A complete lattice is a poset hD; vi, in which every subset X D has a Fsup ( X ) and, therefore, an inf (uX ). An element c 2 D is compact if and only if c v X implies c v F Y for some nite Y X , where X is an arbitrary subset of D. As usual K (D) denotes the set of compact elements of D. For X D, we write # X = fd 2 D j 9d0 2 X: d v d0g for the left-closure of X , and K (d) = K (D)\ #Ffdg. A lattice is algebraic if it is complete, and for every d 2 D K (d) is directed and d = K (d). D is !-algebraic if it is algebraic and K (D) is denumerable. Let M (D) be the set of all nite non-empty subsets of K (D). We introduce three preorders on M (D): Smyth's preorder (vS ), Egli-Milner preorder (vEM ) and the new preorder ( ). 2.1. Definition. Let u; v 2 M (D): (i) u vS v if and only if for all e 2 v there is d 2 u such that d v e; (ii) u vEM v if and only if u vS v andF for allF d 2 u there is e 2 v such that d v e; (iii) u v if and only if u vS v and u v v; (iv) 'S , 'EM and ' are the equivalences over M (D) induced by vS , vEM , and , respectively.
10
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
As an immediate consequence of this de nition we have the following properties of . 2.1. Lemma. ForFall u; v 2 M (D): (i) u ' u [ f ug; F (ii) u v , u [ f ug vEM v [ fF vg. (iii) (M (D); ) is a sup-semilattice. The join is given by u t~ v = fa t b j a 2 u & b 2 vg: Proof. We prove just (iii) The correctness of the de nition of u t~ v relies on the closure of K (D) under nite join. Obviously u; v u t~ v. Let u w, v w, for w 2 M (D). Fix any element c 2Fw. Then 9a 2Fu; b 2 v:a v c & b v c, hence a t b v c. This proves u t~ v vS w. F Moreover ( u) t ( v) v w. Therefore u t~ v w. 2 A feature of this preorder is that set theoretic union distributes over t~ and viceversa, up to ', that is (u t~ v) [ w ' (u [ w) t~ (v [ w) and (u [ v) t~ w ' (u t~ w) [ (v t~ w): Recall that an ideal is a non-empty left-closed set, closed under joins of nite subsets. The ideal completion Idl(P; v) of the poset (P; v) is the set of all ideals ordered by subset inclusion. We now de ne our powerdomain constructor. 2.2. Definition. Let D be an algebraic lattice: (i) P (D) = Idl(M (D); ); (ii) fj jg : D ! P (D) is de ned by: fjdjg = fv 2 M (D) j 9c 2 K (d) : v fcgg; (iii) ] : P (D) P (D) ! P (D) is de ned by: s ] t = #fu [ v j u 2 s; v 2 tg. It is easy to check that fj jg and ] are well de ned. To shorten notation fjd1; : : : ; dnjg will abbreviate fjd1jg ] : : : ] fjdnjg. P (D) is naturally ordered by subset inclusion, and moreover it is a complete lattice. In fact we get: _ [ X = fu 2 M (D) j 9 u1; : : :; un 2 X: u u1 t~ t~ un g for an arbitrary X P (D). By construction P (D) is algebraic, with basis K (P (D)) = f# u j u 2 M (D)g, where # u = fv 2 M (D) j v ug. Therefore, if D is !-algebraic, then P (D) is as well. The distributivity of join with respect to union in M (D) induces that of join over ] in P (D), and viceversa: (r _ s) ] t = (r ] t) _ (s ] t) and (r ] s) _ t = (r _ t) ] (s _ t): The powerdomain P (D) enjoys some \set theoretical" properties, among which the most interesting is that the set of ]-irreducible elements coincides with the set of \singletons". 2.3. Definition. Let D be an algebraic lattice, then: (i) the set C (P (D)) of ]-irreducible elements of P (D) is de ned by: r 2 C (P (D)) , 8s; t 2 P (D): s ] t r ) s _ t r; (ii) given s 2 P (D) de ne C (s) = fC fne C (P (D)) j U C 2 K (s)g, where fne is short for \is a nite non-empty subset of". Notice that for all s 2 UP (D) and C 2 C (s), C K (P (D)) (otherwise a contradiction immediately arises from C 2 K (s)). 2.2. Lemma. Let D be an algebraic lattice, then:
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
11
(i) the set C (P (D)) is the image of D under the mapping fj jg; (ii) for all s 2 K (P (D)), ifW sU6= ? then there exists C fne C (P (D)) such that s = U C ; (iii) for all s 2 P (D), s = f C j C 2 C (s)g. Proof. (i) For any d 2 D and s; t 2 P (D), we show that ifFs ] t fjdjg, then s _ t fjdjg. Notice that by De nition 2.1 u fcg if and only if u v c. Given any w 2 s _ t there are u; v 2 M (D) such that u 2 s; v 2 t and w u t~ v. This implies that G G G w v (u t~ v) = (u [ v); where the joins are taken in D. By the de nition of fjdjg, sF] t fjdjg implies that there c 2 K (d) such that u [ v fcg, and also that (u [ v) v c. Therefore F w vexists c, so we conclude w 2 fjdjg. This shows that s _ t fjdjg, by the arbitrariness of w. Viceversa suppose that s 2 P (D); if u 2 s and u = fe1; : : :; Feng then fje1jg]]fjenjg s. If s is ]-irreducible, this implies fje1jg _ _ fjenjg = fj in eijg s. Given an ]-irreducible s, let S = Sfu j u 2 sg, and d = F S . We show that S is directed. If c; c0 2 S then there are u; v 2 s such that c 2 u; c0 2 v. Since s is an ideal with respect to , u t~ v 2 s. Moreover c t c0 2 u t~ v, and therefore c t c0 2 S . Now on one hand we have G u 2 s ) u S ) u 2 K (d) ) u 2 fjdjg: On the other hand, using the ]-irreducibility of s, we have w 2 fjdjg ) 9c 2 K (d): w fcg ) 9c0 2 S: w0 fc0g 0 ) 9u 2 s; c 2 u: w fc g ) 9u 2 s; c1; : : :; cn 2 K (D): u = fc1; : : : ; cng & w 2 fj Fin cijg ) w 2 s; where the second implication follows from the facts that c is compact and S directed. We conclude that s = fjdjg. (ii) If s 2 K (P (D)), then it is in the image of M (D) under the natural embedding of M (D) into P (D). Therefore, for some e1; : : :; em 2 K (D), s = fje1; : : :; emjg. Now the statement follows from (i). (iii) Immediate from (ii) and the fact that P (D) is algebraic.
2
2.1. Corollary. Let r be a compact and ]-irreducible element of P (D), then r = s ] t, where s and t are compacts, implies r = s = t. Proof. By Lemma 2.2 (i), there exists e 2 K (D) such that r = fjejg. Let s =# fug, t =# fvg, for u; v 2 M (D). Since feg u [ v, we have in particular 8d 2 u: e v d and 8d0 2 v: e v d0: This trivially implies feg u and feg v. On the other hand, since u t~ v feg, we have F(u [ v) v e, hence immediately we conclude u feg and v feg. Thus it is the case r = s = t. 2 P can be turned into a functor. For this aim we rst introduce the category oper-ALG of oper-lattices (lattices with an operation).
12
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
2.4. Definition. The category oper-ALG of oper-lattices is the following. (Objects) An object in oper-ALG is a !-algebraic lattice D equipped with a continuous binary operation D : D D ! D such that (omitting the subscript): (i) d1 d2 = d2 d1 (commutativity), (ii) d1 (d2 d3 ) = (d1 d2) d3 (associativity), (iii) d d = d (idempotency), (iv) (d1 d2) t d3 = (d1 t d3) (d2 t d3) (join distributivity). (Morphisms) A morphism f : D ! E from D to E is a continuous function such that f (d D d0) = f (d) E f (d0 ) E f (d t d0); (19) for d; d0 2 D. 2.1. Proposition. oper-ALG is a well de ned category. Proof. Let (D; ) be an oper-lattice. For IdD to be a morphism we have to prove d e = d e (d t e), for any d; e 2 D. We have d e = (d e) t (d e) (idempotency) = (d t (d e)) (e t (d e)) (distributivity) = (d t d) (d t e) (e t e) (d t e) (distributivity and associativity) = d e (d t e) (commutativity and idempotency) We prove that morphisms are closed under composition. First we note that d1 v d2 v d3 ) d1 d3 = d1 d2 d3 (20) Indeed d1 d3 = d1 d1 d3 by idempotency of v d1 d2 d3 by monotonicity of v d1 d3 d3 by monotonicity of = d1 d3 by idempotency of Now let f : (D; D ) ! (E; E ), g : (E; E ) ! (C; C ) be morphisms. Then (omitting subscripts) (g f )(d e) = g(f (d) f (e) f (d t e)) = g(f (d) f (e)) (g f )(d t e) g((f (d) f (e)) t f (d t e)) = g(f (d) f (e)) (g f )(d t e) (a) = (g f )(d) (g f )(e) g(f (d) t f (e)) (g f )(d t e) = (g f )(d) (g f )(e) (g f )(d t e) (b) where in (a) we use the fact that, by the monotonicity of f , f (d); f (e) v f (d t e), so that f (d) f (e) v f (d t e) by monotonicity and idempotency of . In (b), since f (d) t f (e) v f (d t e), we know that g(f (d) t f (e)) v (g(f (d t e)) by the monotonicity of g. On the other hand (g f )(d) (g f )(e) v g(f (d) t f (e)) by a reasoning similar to that in (a); then (b) follows by (20).
2
2.1. Theorem. Let ALG be the category of algebraic lattices with Scott continuous functions as morphisms. Then the forgetful functor F : oper-ALG ! ALG has a left adjoint whose action on objects is given by P (more precisely, each lattice D is transformed into the oper-lattice (P (D); ])).
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
13
Proof. We take the characterization of adjunction given in [28], Theorem IV.2.(ii). fj jg : D ! F (P (D)) is an universal arrow from D to F . In fact, let E be any oper-lattice and f : D ! F (E ) a continuous function. Then there exists a unique morphism f y : P (D) ! E such that f = F (f y) fj jg, namely the unique continuous extension of G f y(fjd1; : : : ; dnjg) = f (d1 ) : : : f (dn ) f ( di): in
This de nes the action of P on morphisms: if D0 is an algebraic lattice and g : D ! D0 a continuous function, then P (g) = (fj jg g)y.
2
In order to get a domain suitable for our purposes we look for the initial solution, D1 , of the domain equation D = P ([D ! D]?); (21) 1 where we identify P and F P . As seen in the Introduction, the initial solution N of N = [P (N?) ! P (N?)]: (22) is immediately recovered from D1 as N 1 = [D1 ! D1 ]. The existence of the domain D1 is assured by general results on xpoint domain equations, providedFthat we canFprove that P is locally continuous, that is for any chain fn : D ! E it holds P ( n2 fn) = n2 P (fn). F Let f = n2 fn. Then P (f ) is the unique continuous extension of fjd1; : : : ; dmjg 7! fjf (d1); : : : ; f (dm ); f (Fim di )jg: Since fjf (d1); : : : ; f (dm); f (Fim di )jg = fj Fn2 fn(d1); : : : ; Fn2 fn (dm); Fn2 fn (Fim di )jg = Fn2 fjfn(d1); : : :; fn(dm ); fn(Fim di)jg; we have that P (f ) extends fjd1; : : :; dm jg 7! Fn2 fjfn(d1); : : :; fn(dm ); fn(Fim di)jg; hence P is locally continuous. Because of the continuity of P , the direct limit technique to compute the initial solution 1 D of equation (21) works (since ( )? is locally continuous as well). D1 is the colimit of the !-chain (Di ; "i)i2 , where D0 = f?g, Dn+1 = P ([Dn ! Dn ]?). The embedding "0 is x: ?. To construct "n+1 suppose "n : Dn ! Dn+1 is given; then "n+1 = P (h? ) where h = f 2 [Dn ! Dn ]: "n f n and n is the projection from Dn+1 to Dn determined by "n. As in the case of the simpler equation modeling the lazy -calculus, this is a non-trivial solution because of the lifting functor. We call the isomorphism D1 ' P ([D1 ! D1 ]?); however we shall identify elements of D1 and P ([D1 ! D1 ]?) when no ambiguity arises. Because of we have a \union" operation over D1 , formally de ned by d ] e = ?1( (d) ] (e)): Compact elements of domains constructed by direct limit are images of compact elements of the approximate domains, so that, up to embedding-projection of each Dn into D1 , we S have K (D1 ) = n2N K (Dn ). They are inductively characterized by the following lemma, whose proof is immediate from the construction of Dn . N
N
N
N
N
N
IN
N
N
14
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
2.3. Lemma. (i) K (D0 ) = f?g; (ii) K (Dn+1 ) = ffjf1; : : : ; fmjg j 1 m; f1; : : :; fm 2 K ([Dn ! Dn]? )g; (iii) K ([Dn+1 ! Dn+1 ]?) = fF1k (ci ) di) j ci; di 2 K (Dn )g [ f?g, where (c ) d)(e) is the step function: if c v e then d else ?. Note that we drop the usual consistency condition in taking nite joins of step functions. This is sound since we work with lattices. To nish up the present section, we study D1 as an applicative structure. Equation (22) clearly falls into the general framework studied in [29]; therefore in the following we concentrate on the categorical side by illustrating how our construction can be seen as an instance of the categorical concept of monad. In detail, we rst prove that P ()? induces a monad over ALG. Then we illustrate how it is possible to de ne an application between elements of D1 by exploiting the fact that P ( )? has a tensorial strength. 2.5. Definition. A monad over a category C is a structure (T; ; ), where T : C ! C is a functor, : Id ! T and : T 2 ! T are natural transformations such that the following diagrams commute:
T 3A T (A )
TA
TA
A
TA
- T 2A
T (A )
TA
QQ Q A QQ IdA IdA QQs ?+ TA
A
?
T 2A
- T 2A ? - TA
The following de nitions of tensorial strength and of strong monads are taken from [29]. 2.6. Definition. Let (T; ; ) be a monad over a category C , which has all nite products. (i) A tensorial strength t of T is a family of morphisms tA;B : A T (B ) ! T (A B ) indexed over pairs of objects of C , such that for all points a : 1 ! A and b : 1 ! T (B ) it holds tA;B ha; bi = T (ha!B; IdB i) b; (23) where !B : B ! 1 is the unique morphism from B to the terminal object. (ii) If t is a tensorial strength of (T; ; ), then (T; ; ; t) is called a strong monad. In [29] it is shown that, if C has enough points, then the tensorial strength of a monad T (if it exists) is uniquely determined. The notion of exponents in a cartesian category can be specialized to a strong monad over that category as follows. 2.7. Definition. Let C be a cartesian category and (T; ; ; t) a strong monad over C . Then T : T (B )A A ! T (B )i, with the universal property: a T -exponential is a pair hT (B )A; evalA;B T T (f ) Id ; 8f : C A ! T (B ) 9!T (f ) : C ! T (B )A: f = evalA;B A that is the following diagram commutes:
- T (B ) 3 eval T (f ) IdA T A;B ? T (B )A A C A
f
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
15
A call-by-name T -re exive object is an object N of C such that there is a retraction T (N )T (N ) N , say via ( N ; 'N ). Let A;B : A B ! B A be the obvious isomorphism, and de ne ~tA;B : T (A) B ! T (A B ) by t~A;B = T () tB;A : Then the following diagram de nes the call-by-name T -application morphism appN : T (N ) T (N ) ! T (N ):
T (N ) T (N ) t~N;T (N )
?
appN
??
- T (N ) ? ? ? N
- T 2(N ) ? ? T ('N IdTN ) ? T (evalTT (N );N ) ? ? T (T (N )T (N ) T (N )) ? T (evalTT (N );N 'N IdT N )
T (N T (N ))
2.2. Proposition. Let T be the functor P ( )? . The quadruple (T; T ; T ; tT ) is a strong monad over the category ALG, where: (i) DT : D ! T (D) is the map d 7! fj(d; 0)jg; (ii) TD : T 2(D) ! T (D) is the unique continuous strict morphism of oper-lattices which extends fjfj(d1; 0); : : : ; (dn; 0)jgjg 7! fj(d1; 0); : : :; (dn ; 0)jg; fjfj(d1; 0); : : : ; (dn ; 0); ?jgjg 7! fj(d1; 0); : : :; (dn ; 0); ?jg: (iii) tTD;E is the unique continuous extension of the map (d; fj(e1; 0); : : : ; (en; 0)jg) 7! fj((d; e1); 0); : : : ; ((d; en); 0)jg; (d; fj(e1; 0); : : :; (en; 0); ?jg) 7! fj((d; e1); 0); : : : ; ((d; en); 0); ?jg: Proof. Consider the subcategory A0 of oper-ALG whose objects are oper-lattices and whose morphisms are strict morphisms of oper-lattices. Then the forgetful functor F : A0 ! ALG has T as a left adjoint: for each D, DT : D ! T (D) is an universal arrow from D to F . In fact for each f : D ! E , where E is an oper-lattice, there exists a unique strict morphism of oper-lattices f 0 : T (D) ! E such that f 0 DT = f . Indeed f 0 extends the morphism which F sends fj(d1; 0); : : :; (dn ; 0)jg to f (d1) : : : f (dn ) f ( in di) and fj(d1; 0); : : :; (dn ; 0); ?jg to f (d1) : : : f (dn ) f (Fin di ) ?. The thesis follows from the fact that each adjunction determines a monad (see [28], Section VI.1). In particular the de nition of T satis es T = T , where is the counit of the adjunction. As regards tT , consider that, since ALG is a concrete category, it has enough points. Moreover it has all nite products. Therefore the tensorial strength is uniquely characterized by equation (23).
2
We give an explicit de nition of the application over D1 , and we show that it coincides with the call-by-name T -application morphism determined by the monad P ()?.
16
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
2.3. Proposition. Consider the map : P ([D1 ! D1 ]?) D1 ! D1 which is the unique continuous extension of the map from K (P ([D1 ! D1 ]?) D1 ) = K (P ([D1 ! D1 ]?)) K (D1 ) to K (D1 ) de ned by 8 < f1(d) ] ] fm(d) if 8i m: fi 6= ? fjf1; : : : ; fmjg d = : f1(d) ] ] fm?1(d) ] ? if 8i m ? 1: fi 6= ? and fm = ?. Then for all d; e 2 D1 and taking N = N 1 = [D1 ! D1 ],
d e = appN (d; e): Proof. The call-by-name T -re exive object of our construction is the initial solution N 1 of the equation (22). On the other hand we have that, up to isomorphism, the following equations hold (writing simply D for D1 and N for N 1)
T (N ) = P (N?) = P ([D ! D]? ) = D; so that
T (N ) T (N ) = P ([D ! D]? ) D: If u = fjf1; : : : ; fmjg 2 K (P ([D ! D]? )) = K (T (N )) and d 2 D, then 8 < fj(f1; d); : : :; (fm; d)jg if f1; : : :; fm 6= ? t~N;T (N )(u; d) = : fj(f1; d); : : :; (fm?1 ; d); ?jg if f1; : : :; fm?1 6= ? and fm = ?:
In any case this \set" is an element of T (N T (N )) = T (T (N )T (N ) T (N )), and the T -evaluation morphism evalTT (N );N : T (N )T (N ) T (N ) ! T (N ) is given by 8 evalT (f; d) = f (d) if f 2 N = [D ! D] = T (N )T (N ) < T (N );N : evalTT (N );N(?; d) = ?: Therefore we have, when f1; : : :; fm 6= ?, that (ignoring the isomorphism 'N = ): app N (u; d) = N T (evalTT (N );N ) t~N;T (N )(u; d) = N T (evalTT (N );N)(fj(f1; d); : : : ; (fm; d)jg) = N (fjevalTT (N );N(f1; d); : : : ; evalTT (N );N(fm ; d)jg) = N (fjf1(d); : : : ; fm(d)jg) = f1(d) ] ] fm(d) = fjf1; : : : ; fmjg d: Similarly, if f1; : : : ; fm?1 6= ? and fm = ? then app N (u; d) = f1(d) ] ] fm?1 (d) ] ?.
2
We nally include the de nition of an operator ` which roughly computes the join of the elements of a set. 2.8. Definition. De ne ` : D1 ! D1 as the unique continuous extension of
`(?) = ?
`(fjd ; : : :; d jg) = fj F d jg: 1 n in i
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
17
3. A Logical Presentation Logical presentations are useful tools for de ning and studying models [2]. We use intersection types, which provide simple descriptions of !-algebraic lattices. Types are formed by starting with the universal type ! and closing under the arrow, which is used for describing the function space, under the intersection, which corresponds to the semantic join (as in [11, 15, 14]), and under a new type constructor , which represents the restriction of the semantic operation to compacts. In determining the structure of the space of lters, i.e. the structure of the domain of the model, the choice of the ordering over types is crucial. We describe the order and its properties in subsection 3.1. Subsection 3.2 gives the isomorphism between the space of lters and the initial solution of our powerdomain equation.
3.1. The Set of Types
The set Type of types is de ned by adding the type constructor \sum" to the intersection types [9, 12]: ::= ! j ! j ^ j : In writing types we assume that ^ and take precedence over !. We look for a partial order over types which corresponds in a natural way to the (quotient of the) preorder de ned on M (D) in Section 2. This will be clari ed by the properties we will show of this order. 3.1. Definition (Preorder on Types). Let be the least preorder over Type such that: (i) !; (ii) ! ! ! ! !; (iii) ^ ; (iv) ^ ; ^ ; (v) 0; 0 ) ^ 0 ^ 0; (vi) ; (vii) ; (viii) ( 0) ( ) 0; (ix) 0; 0 ) 0 0; (x) ( 0) ^ ( ^ ) (0 ^ ); (xi) ( ! ) ^ ( ! 0) ! ( ^ 0); (xii) 0 ; 0 ) ! 0 ! 0. Let = be de ned as \ and ". Then the quotient structure hType==; ==i is a topped inf-semilattice, where the top is [!] and [] ^== [ ] = [ ^ ]. As usual we identify Type with Type== and with ==. We write < if and only if and 6= . 3.1. Proposition. The axiomatic presentation of De nition 3.1 is consistent, and therefore hType; i is a non-trivial structure. In particular: ! 6 ! ! !: Proof. Let f : Type ! f?; >g be the following map into the two points lattice, ordered by ? v >: f (!) => f ( ! ) = ? f ( ^ ) = f ( ) = f () u f ( ): Checking through De nition 3.1 we see that ) f () v f ( );
18
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
for all and (actually f is a meet-semilattice morphism). Now f (!) = > 6v ? = f (! ! !) implies the thesis by contradiction.
2
Notation. Because of its relevance and frequent occurrences in the technical development, we abbreviate ! ! ! by !1 . We have the distributivity of ^ with respect to and the viceversa. 3.1. Lemma. For all ; 0; ; 0 2 Type: (i) ( 0) ^ = ( ^ ) (0 ^ ); (ii) ( ^ 0) = ( ) ^ (0 ). Proof. (i) Because of De nition 3.1 (x), it suces to show that ( ^ ) (0 ^ ) ( 0) ^ . This follows from ( ^ ) (0 ^ ) 0, by De nition 3.1 (iv) and (ix), and from ( ^ ) (0 ^ ) , by De nition 3.1 (iv), (ix) and (vi). (ii) ( ^ 0) ( ) ^ (0 ) follows, by De nition 3.1 (v), from ( ^ 0) and ( ^ 0) 0 , which in turn hold by De nition 3.1 (iv) and (ix). For the opposite inclusion, using (i) of the present Lemma, we have: ( ) ^ (0 ) = ( ^ (0 )) ( ^ (0 )) = ( ^ 0) ( ^ ) (0 ^ ) ( ^ ) ( ^ 00) = ( ^ ) :
2
Notation. Let I; J; H; K; : : : be nite sets of indexes. Since ^ and are commutative and
associative, we will freely use the following notations: V ; V ; L ; L ; i2I i in i i2I i in i with obvious meanings. A key equation, derivable from the above axioms, is = ( ^ ). This can be generalized as follows: 3.2. Proposition. L = L V : (P0) in i in i in i Proof. By induction on n. V L V L ^ = i n +1 i n +1 i i in in in+1 in+1 L V = in i n+1 in i ^ Lin i n+1 n+1 by distributivity L L = in i n+1 ^ in i n+1 by induction and idempotency of : =L in+1 i
2
The following notion of irreducible types is the counter-part of the notion of singletons.
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
19
3.2. Definition. A type is irreducible if and only if 8; 2 Type: = ) = = : IType is the set of irreducible types dierent from !. The exclusion of ! from IType is accounted for by the fact that ! itself is irreducible (see Corollary 3.1 (i) below), and because irreducible types dierent from ! play a central role in the semantic construction. We rst prove that any type is equivalent to a nite sum of irreducible types (possibly including !), and that the restriction of the inequality relation to irreducible types characterizes the relation itself over the whole set Type. It is useful to introduce a map which drops external ; we will see that returns nite sets of irreducible types. 3.3. Definition. Let : Type ! }(Type) be de ned as follows: (i) (!) = f!g (ii) ( ! ) = f ! g (iii) ( ) = () [ ( ) 8 f0 2 () j ! 2 ( )g [ > < (iv) ( ^ ) = > f 0 2 ( ) j ! 2 ()g [ : f0 ^ 0 j 0; 0 6 ! & 0 2 () & 0 2 ( )g: Informally, we may compute () as follows: Step 1: by distributing ^ over , put into a -normal form, i.e. a sum of conjunctions of arrow types and ! (this preserves equality by Lemma 3.1 (i)); Step 2: in each term of the above sum, erase any occurrence of ! in conjunction with some arrow type (which again is justi ed by the axioms of the equality); Step 3: then () is just the nite set of conjunctions in the sum obtained from step 2. 3.1. Example. ((! ! !) ^ !) = f! ! !g; ((! ! !) !) = f! ! !; !g; ((! ! !) ^ ((! ! ! ! !) !)) = f! ! !; (! ! !) ^ (! ! ! ! !)g = (((! ! !) ^ (! ! ! ! !)) ((! ! !) ^ !)): 3.3. Proposition . For all ; 2 Type: (i) = L0 2() 0; V (ii) if and only if 02() 0 V 02( ) 0 and 80 2 () 9 0 2 ( ): 0 0; (iii) is irreducible if and only if 80 2 (): = 0; (iv) IType and IType [ f!Vg are closed under intersection; (v) for all I; i; i we have i2I (i ! i ) 2 ITypeV; (vi) 0 2 () implies either that 0 ! or 0 i2I (i ! i) for some i ; i and I ; (vii) () is a set of irreducible types. Proof. (i) By easy induction on the de nition of using the distributivity of over ^. (ii) ()). By induction on the presentation of . ((). Let () = fi j i 2 I g and V( ) = fVj j j 2 J g. By hypothesis for all i 2 I there exists ji 2 J such that i ji and i2I i j2J j . Now V =L i2I i ( Vi2I i ) by (i) and (P0) L Li2I ji ( j2J j ) by hypothesis j2J j by monotonicity and idempotency of = :
20
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
(iii) ()) follows by de nition of IType and by (i). ((). Let () = fi j i 2 I g, ( ) = fj j j 2 J g and () = fk j k 2 K g. If = then ^ ^ ^ = i = j ^ k ; i2I
j 2J
k2K
by the hypothesis that = i for all i 2 I , and by (ii): therefore and . On the other hand and the hypothesis on imply, by (ii), that j for all j 2 J and k for all k 2 K . We conclude that and , so that = = . (iv) Immediate by (iii) and by Vde nition of ( ^V ). (v) It is easy to verify that ( i2I (i ! i)) = f i2I (i ! i)g, so we are done by (iii). (vi) By a straightforward induction on the de nition of . (vii) Immediate by (v) and (vi).
2
3.1. Remark. The key point in Proposition 3.3 is (ii). Comparing this statement with the de nition of the (pre)order over M (D) it is apparent that and are dual to each other. A stronger correspondence is property (P2) in Lemma 3.2. Point (vi) clearly gives a characterization of irreducible types, while (i) assures that the function is the right tool to compute type inequalities. 3.1. Corollary. (i) ! is irreducible; (ii) !1 < !1 ! < !; (iii) !1 , ! 62 () , 6= !; (iv) = ! & 6= ! ) !1 ! and ! 2 (). Proof. (i) For any ; 2 Type, by Proposition 3.3 (ii) ! ) ! V02() 0 ^ V 02( ) 0 0 0 0 0 ) 8 2 () 8 2 ( ): ! & ! )! = = by Proposition 3.3 (i). (ii) By De nition 3.1 (i), (vi) and (ix) we prove !1 = !1 !1 !1 ! ! ! = !: !1 ! 6 !1 and ! 6 !1 ! are consequences of Proposition 3.3 (ii) using the fact that ! 6 !1, by Proposition 3.1. (iii) By Proposition 3.3 (i) and (ii) of this Corollary, we know that 6= ! if and only ). This implies by Proposition 3.3 (vi) that all 0 2 () have the shape V (if !!2= ( i ), for some I; i; i . By this, De nition 3.1 (i), 3.1 (ii) and 3.1 (xii), Proposition i2I i 3.3 (i) and De nition 3.1 (vi), the thesis follows. (iv) = ! & 6= ! ) = L02()nf!g 0 ! ) !1 ! using Proposition 3.3 (i), 3.3 (vi), and point (iii) of this Corollary. ! 2 ( !) by de nition, so ! 2 () by Proposition 3.3 (ii).
2
We nish this section with two technical lemmas stating the main properties of .
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
21
3.2. Lemma. (P1) implies that for some one has = L ; L (P2) VLet i; jVbe irreducible types for i 2 I; j 2 J: i2I i j2J j if and only if i2I i j 2J jVand, for all i 2 I; there is j 2 J such that i j ; L (P3) V i2I i ! = ( Vi2I i) !; (P4) i2I (i ! i) j2J (Vj ! j ) if and only if, for all j 2 J such that j 6= !, there is I I such that and V ; Proof.
j
j
i2Ij i
i2Ij i
j
(P1) Let () = fi j i 2 I g and () = fh j h 2 H g, for some I; i; H; h. By Proposition 3.3 (ii) we know that
) 8i 2 I 9 hi 2 H: i hi : Set = Li2I hi : then by construction and = by the idempotency, commutativity and associativity of . L ) (P2) It Sfollows from Proposition 3.3 (ii), considering that, by de nition, we have ( i2I i = i2I (i) and (Lj2J j ) = Sj2J (j ). Moreover i = i0 for all i0 2 (i) and j = j0 for all j0 2 (j ) by Proposition 3.3 (iii), since i and j are irreducible by hypothesis. (P3) Immediate from (P2). (P4) De ne the map : Type ! }(IType) as follows: (i) (!) = ;; (ii) ( ! ) = f ! g; (iii) ( ) = ( ^ ) = () [ ( ). Let () = fi ! i j i 2 I g and ( ) = fj ! j j j 2 J g for some (possibly empty) I; J . We establish the following more general statement, of which (P4) is a particular case: , [( ) = ;] or [(() 6= ;) & (8j 2 J: j 6= ! ) 9 Ij I: j Vi2Ij i & Vi2Ij i j )]: The proof is by induction on the de nition of . All cases are immediate except transitivity. Suppose that because of for some . Let ( ) = fh ! h j h 2 H g. If ( ) 6= ; then, by induction, ( ) 6= ;. The induction hypothesis gives: (24) 8h 2 H: h 6= ! ) 9 Ih I: h ViV2Ih i & Vi2VIh i h; 8j 2 J: j 6= ! ) 9 Hj H: j h2Hj h & h2Hj h j : (25) For any j 6= ! set Hj0 = fh 2 Hj j h 6= !g, which is nonempty as a consequence of (25). Then j Vh2Hj0 h and Vh2Hj0 h j : (26) By (24) we know that
h 2 Hj0 ) h Vi2Ih i & Vi2Ih i h ; therefore Vj VVh2Hj0 h VVh2Hj0 (Vi2Ih i) by (26) and (27) h2Hj0 ( i2Ih i ) h2Hj0 h j by (27) and (26) so that we set Ij = Sh2Hj0 Ih.
(27)
22
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
2 Property (P2) explicitly relates to the ordering in the powerdomain constructed in Section 2. More precisely the ordering on types is dual to the preorder on M (D), when we interpret as union operator (]) and ^ as join ( t~ ). In fact, in Section 6 we will see that the quotient of types under = gives the dual of an oper-lattice. Property (P4) assures the representability of continuous functions. Let us assume that ; ; ; correspond to the domain elements s; t; m; n (possibly with indexes). If we regard ! as corresponding to the step function s ) t, we can rewrite (P4) as the following standard implication: G G (si ) ti) (mj ) nj ) if and only if i2I
8i 2 I: 9J 0 J:
j 2J
G
j 2J 0
mj si & ti
G j 2J 0
nj ;
which implies the usual representability of continuous functions as joins of step functions (see also the proof of Theorem 3.1 and [12, 13]). 3.2. Remark. The hypothesis j 6= ! cannot be dropped in (P4). Indeed, by De nition 3.1 (ii) and (xii) we have, for any , ! ! = ! ! !: This implies that, for any choice of ; and , ! ! ! ! = ! !: So that (P4) would fail as soon as 6 . 3.3. Lemma. Suppose that ^ Li2I ( ! i), then: (P5) if ; !1 then there exist fj j j 2 J g and fl j l 2 Lg such that Lj2J ( ! j ); Ll2L( ! l); and (Lj2J j ) ^ (Ll2L l) Li2I i;
(P6) if !1 and = ! 6= ! then there exist fj j j 2 J g and fl j l 2 Lg such that L Lj2J ( ! j ); LlL 2L( ! l ) ! and L ( j2J j ) ^ ( l2L l !) i2I i : If instead ^ Li2I ( ! i ) !, then: (P7) if ; 6= ! then there exist fj j j 2 J g and fl j l 2 Lg such that L Lj2J ( !Lj ) ! LLl2L( ! l) ! and [( j2J j ) ^ ( l2L l)] ! i2I i !: Proof.
(P5) Let () = fh j h 2 H g and () = fk j k 2 K g. As ; !1, ! 62 () [ () by Corollary 3.1 (iii). Therefore ( ^ ) = fh ^ k j h 2 H; k 2 K g. Moreover let h = Vr2Rh (h;r ! h;r) and k = Vs2Sk ( k;s ! k;s). De ne R0h = fr j h;r g and Sk0 = fs j k;s g. Clearly R0h Rh ; Sk0 Sk and some of them may be empty. We set intersections indexed by the empty set to !.
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
23
(28) ^ Li2I ( ! i ) ) ) 8h 2 H; k 2 K: 9f (h; k)V2 I:h ^ k V ! f (h;k) by (P2) ) 8h 2 H; k 2 K: 9f (h; k) 2 I: r2R0h h;r ^ s2Sk0 k;s f (h;k) by (P4). (29) by (P2) ^ Li2I ( ! i ) ) Vh2H;k2KV(h ^ k ) Vi2I ( ! i) ) 8i 2 I: Vh2H;k2K (Vh ^ k ) V! i ) 8i 2 I: h2H;k2K ( r2R0h h;r ^ s2Sk0 k;s) i by (P4) (30) ) Vh2H;k2K (Vr2R0h h;r ^ Vs2Sk0 k;s ) Li2I i: Therefore we can put J = H , L = K , j Vr2R0j j;r , and l Vs2Sl0 l;s, where j 2 J and l 2 L (always setting intersections on the empty set to !). Now (29) and (30) can be rewritten respectively as:
9f (j;Ll) 2 I:j ^ l f (j;l); V8j 2 J; l(2 L: : ^)
(31) (32) l i2I i j 2J;l2L j It is easyLto verify that j ! j and l ! l. This implies Lj2J ( ! j ) and l2L( ! l). Moreover we have: L (Lj2J j ) ^ (Ll2L l) = L j 2J;l2L(j ^ l ) = Lj2J;l2L(j ^ l)L (Vj2J;l2L(j ^ l)) by (P0) j2J;l2L f (j;l) i2I i by (31) and (32) = Li2I i: (P6) VBy Proposition 3.3 V(i) and (P3)V = (V02() 0) !, which implies ^ = ( ^ 0 0 0 0 0 2() ) . Let 0 2() = k2K ( k ! k ), K = fk j k g, and h ; Rh be as in the proof of (P5). by (P2) ^ Li2I ( ! i ) ) 8h 2 H:9g(h) 2 I: Vh ! g(h) ) 8h 2 H:9g(h) 2 I: r2R0h h;r g(h) by (P4) (33) and
V
V
V
Li2I i: (34) We choose J; j ; L as in the proof of (P5), l = l if l 2 K 0, l = ! otherwise; then h2H ( r2R0h h;r ) ^ k2K 0 k
(33) and (34) can be rewritten as follows: 8Vj 2 J:9g(j ) 2 I: jL g(j), (35) (36) j 2J;l2L(j ^ l ) i2I i . L L It is easy to verify that j2J ( ! j ) and l2L( ! l) !. We conclude observing that: L ] (Lj2J j ) ^ [Ll2L l !] = [L ( ^ )] [ j l j 2 J;l 2 L j 2J j = [Lj2J;l2L(j ^ l)] [Lj2J j ] [Vj2J;l2L(j ^ l)] by (P0) Lj2J g(j) Lj2J g(j) Li2I i by (35), (36) = Li2I i :
24
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
(P7) Notice that ^V Li2I ( ! i ) !V implies ( ^V) ! Li2I ( ! i) !. Now, V let 02() 0 = h2H (h ! h), and 02() 0 = k2K ( k ! k). By (P3) and (P2) M ^ ^ ^ ( ^ ) ! ( ! i) ! ) (h ! h) ^ ( k ! k ) ( ! i): i2I
h2H
i2I
k2K
Let again H 0 = fh j h g, K 0 = fk j k g. We get, by (P4), ^ ^ ^ (h ! h) ^ ( k ! k ) ( ! i) ) h2H
^ h2H 0
;k2K
h ^
^ k2K 0
k
^ i2I
i2I
i:
Therefore we can choose J = H , L = K , j = V j if j 2 H 0, j = ! otherwise, l = l if l 2 K 0, l = ! otherwise. In fact we have: j2J ( ! j )!, Vl2L( ! l)!. Finally [(L ) ^ (L )] ! L !, since V ^ V V . j 2J j
l2L l
i2I i
j 2J j
l2L l
i2I i
2
3.2. Isomorphism between D1 and F We claim that the set F of lters over Type, ordered by subset inclusion, is isomorphic to 1
D as oper-lattice. We rst show that they are isomorphic as !-algebraic lattices. 3.4. Proposition. The poset (F ; ) is an !-algebraic lattice where the meet is the intersection and the join is the least lter including the union, i.e. F [ F 0 =" f ^ j 2 F; 2 F 0g. The compact elements of (F ; ) are the principal lters " =def f 2 Type j g. Proof. Standard.
2
By this proposition the isomorphism F ' D1 inside the category ALG is established if there is a one-to-one order preserving map between compact elements of these domains. This is equivalent to have a surjective map ( )+ : Type ! K (D) such that if and only if ( )+ v ()+, for all types ; . 3.4. Definition.
(i) The map ( )+ : Type ! K (D1 ) is de ned by: (!)+ = ?; ( ! )+ = fj()+ ) ( )+jg; ( ^ )+ = ()+ t ( )+ ; ( )+ = ()+ ] ( )+ :
(ii) : F ! D1 is the unique continuous extension of the map ( )+ , that is: G (F ) = f()+ j 2 F g: The map is well de ned by Lemma 2.3 and by the fact that the join of compact elements is compact. 3.1. Theorem. The map ( )+ is surjective and such that ()+ v ( )+ if and only if . Therefore is an isomorphism in the category ALG.
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
25
Proof. To see that ( )+ is surjective we show that for all n, K (Dn ) (Type)+ by induction on n. In fact f(!)+ g = K (D0) = f?g which establishes the thesis when n =F0. Let e = fjf1; : : : ; fmjg 2 K (Dn+1 ). Then for all i m, either fi = j2Ji (e(ji) ) d(ji)), where Ji is a nite set of indexes and e(ji); d(ji) 2 K (Dn ) for all j 2 Ji, or fi = ?. In the latter case, by the idempotency of ], we can suppose that there is just one i m such that fi = ?. By induction there are types (ji); j(i) such that ((ji))+ = e(ji) and (j(i))+ = d(ji). Then, if fi 6= ? for all i, we have
e = [Lim (Vj2Ji (ji) ! j(i))]+;
otherwise let fm = ?, then e = [Lim?1 (Vj2Ji ((ji) ! j(i))) !]+: We are left to show that , ( )+ v ()+: The ()) part can be easily proved by induction on the de nition of . The proof of the (() part is by structural induction on and . The more interesting case is when 2 3 2 3 M 4 ^ (i) (i) 5 M 4 ^ (j) (j) 5 = (h ! h ) and = (k ! k ) ; i2I h2Hi
j 2J k2Kj
for suitable nite sets of indexes and types. Then, if ((hi))+ = e(hi), (h(i))+ = d(hi), ((kj))+ = rk(j), and (k(j) )+ = s(kj), we have: G G ()+ = fj (e(hi) ) d(hi)) j i 2 I jg and ( )+ = fj (rk(j) ) s(kj)) j j 2 J jg: h2Hi
k2Kj
Now fj Fk2Kj (rk(j) ) s(kj)) j j 2 J jg fj Fh2Hi (e(hi) ) d(hi)) j i 2 I jg if and only if: 2 3 2 3 G 4 G (j) (j) 5 G 4 G (i) (i) 5 (rk ) sk ) v (eh ) dh ) j 2J k2Kj
8i 2 I:9j 2 J: Inequation (37) implies that
G k2Kj
i2I h2Hi
(rk(j) ) s(kj)) v
8j 2 J:8k 2 Kj :8i 2 I:9Hi0 Hi :
2 G4 G
i2I h2Hi0
G
h2Hi
(e(hi) ) d(hi)):
(37) (38)
3 3 2 G G e(hi)5 v rk(j) & s(kj) v 4 d(hi)5 : i2I h2Hi0
Notice that some Hi0 may be empty, in which case the corresponding sup is equated to ?. By induction we have 0 1 0 1 ^ ^ ^ ^ ( j ) ( i ) ( i ) 8j 2 J:8k 2 Kj :8i 2 I:9Hi0 Hi : k @ h A & @ h A k(j); therefore by (P4) we get 2 ^4 ^
i2I h2Hi
i2I h2Hi0
i2I h2Hi0
3 2 3 ^ ^ ((hi) ! h(i))5 4 ((kj) ! k(j))5 : j 2J k2Kj
(39)
26
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
Inequation (38) implies that G G 8i 2 I:9j 2 J:8k 2 Kj :9Hi0 Hi: e(hi) v rk(j) & s(kj) v d(hi): h2Hi0
h2Hi0
By induction we have ^ ^ 8i 2 I:9j 2 J:8k 2 Kj 9Hi0 Hi : (kj) (hi) & h(i) k(j) ; h2Hi0
h2Hi0
therefore by (P4) it follows that ^ ^ 8i 2 I:9j 2 J: ((hi) ! h(i)) ((kj) ! k(j) ): h2Hi
k2Kj
Now (39) and (40) imply, by (P2), that L hV ((i) ! (i))i L hV ((j) ! (j))i ; i2I h2Hi h j 2J k2Kj k h k that is .
(40)
2
The isomorphism and the union operation ] over D1 induce on F a continuous binary map : F F ! F . Indeed, since (") = ()+, we immediately have from De nition 3.4 (") ] (" ) = ()+ ] ( )+ = ( )+ = ("( )): This extends by continuity to F F 0 = ?1 ((F ) ] (F 0)) = " f j 2 F & 2 F 0g: Therefore F is turned into an oper-lattice by , so that satis es all conditions of De nition 2.4 and we conclude: 3.2. Corollary. Let : F F ! F be de ned by: F F 0 = " f j 2 F & 2 F 0g: Then the structures (F ; ; ) and (D1 ; ]; v) are isomorphic in oper-ALG. We say that a lter F is -complete if and only if 2 F implies ^ 2 F . Let FC be the set1of -complete lters. Clearly -complete lters are related to ]-irreducible elements of D . Recall the operator C de ned in De nition 2.3 (i): then, abusing notation, we de ne C (D1 ) = ?1(C (P ([D1 ! D1 ]?))): 3.5. Proposition. C (D1 ) = (FC ), therefore FC is the set of \singletons" in F . Proof. It is straightforward to show that G 2 FC , 8F; F 0 2 F : F F 0 G ) F [ F 0 G: Now the thesis follows from De nition 2.3 (i), since ; are isomorphisms.
2
As a consequence, we immediately have that ?1(C (D1 ) \ K (D1 )) is the set of the principal lters " such that is irreducible. Indeed, if 2" and is irreducible, then = ^ ( ) = ( ^ ) ( ^ ); which implies, by irreducibility, = ^ = ^ , that is ^ . Lastly we examine the application between lters induced by the application in D1 .
Alessi, Dezani and de' Liguoro/A Convex Powerdomain over Lattices: its Logic and -Calculus
27
3.4. Lemma. (i) The functional application over D1 induces, via the isomorphism, an application operation over F . More precisely, for all F; F 0 2 F , if F F 0 is de ned as ?1((F ) (F 0)) then we have: F F 0 = fLi2I i j 9 2 F 0: Li2I ( ! i ) 2 F g [ fLi2I i ! j 9 2 F 0: Li2I ( ! i ) ! 2 F g [ " !: Moreover the application distributes to the left over the \union" operation , that is, for any F; F 0; G 2 F , we have: (F F 0) G = (F G) (F 0 G): (ii) Let ` : D1 ! D1 be de ned as in De nition 2.8. If `(F ) = ?1 ( ` (F )) is the induced operation over F , then a (F ) ="f ^ j 2 F g: Proof. (i) Once the main formula has been established, the left distributivity is shown by straightforward calculations. To prove the main formula it suces to consider F and F 0 to be principal lters. Let () = f1; : : : ; mg. We consider two cases, according to whether () contains ! or not. If ! 62 (), then by Proposition 3.3 (iii) and 3.3 (vii) i = Vj2Ji ((ji) ! i(i)) for some J ; (i); (i). Therefore (" ) = fjf ; : : : ; f jg, where f = ( )+ = (V ((i) ! (i)))+ . i
j
i
1
m
i
i
Let (" ) = d, (" j ) = ej , (" j ) = gj . (" ) (" ) = UUim (" i) (" ) = UimfjFfi(d)jg = im j2Ji0 gj(i) = Uim (" Vj2Ji0 j(i)) = (" Lim (Vj2Ji0 j(i))) where Ji0 = fj 2 Ji j e(ji) v dg = fj 2 Ji j (ji)g. De ne i = Vj2Ji0 (ji), i = Vj2Ji0 j(i) and = Vim i . Then L (V ((i) ! (i))) =L im j 2Ji j j Lim (VVj2Ji0 ((ji) ! j(i))) Lim ( j2Ji0 ( ! j(i))) ( ! ): = Hence we conclude
(i)
(i)
(i)
im
(i)
j 2Ji
j
i
i
9 8 =