University of Pennsylvania ScholarlyCommons

IRCS Technical Reports Series Institute for Research in Cognitive Science

October 1997

Functionality, Polymorphism, and Concurrency: A Mathematical Investigation of Programming Paradigms

Peter Selinger University of Pennsylvania

Follow this and additional works at: https://repository.upenn.edu/ircs_reports

Selinger, Peter, "Functionality, Polymorphism, and Concurrency: A Mathematical Investigation of Programming Paradigms" (1997). IRCS Technical Reports Series. 88. https://repository.upenn.edu/ircs_reports/88

University of Pennsylvania Institute for Research in Cognitive Science Technical Report No. IRCS-97-17.

This paper is posted at ScholarlyCommons. https://repository.upenn.edu/ircs_reports/88 For more information, please contact [email protected]. Functionality, Polymorphism, and Concurrency: A Mathematical Investigation of Programming Paradigms

Abstract The search for mathematical models of computational phenomena often leads to problems that are of independent mathematical interest. Selected problems of this kind are investigated in this thesis. First, we study models of the untyped lambda calculus. Although many familiar models are constructed by order- theoretic methods, it is also known that there are some models of the lambda calculus that cannot be non-trivially ordered. We show that the standard open and closed term algebras are unorderable. We characterize the absolutely unorderable T-algebras in any algebraic variety T. Here an algebra is called absolutely unorderable if it cannot be embedded in an orderable algebra. We then introduce a notion of finite models for the lambda calculus, contrasting the known fact that models of the lambda calculus, in the traditional sense, are always non-recursive. Our finite models are based on Plotkin’s syntactical models of reduction. We give a method for constructing such models, and some examples that show how finite models can yield useful information about terms. Next, we study models of typed lambda calculi. Models of the polymorphic lambda calculus can be divided into environment-style models, such as Bruce and Meyer’s non-strict set-theoretic models, and categorical models, such as Seely’s interpretation in PL-categories. Reynolds has shown that there are no set-theoretic strict models. Following a different approach, we investigate a notion of non-strict categorical models. These provide a uniform framework in which one can describe various classes of non-strict models, including set-theoretic models with or without empty types, and Kripke-style models. We show that completeness theorems correspond to categorical representation theorems, and we reprove a completeness result by Meyer et al. on set- theoretic models of the simply-typed lambda calculus with possibly empty types. Finally, we study properties of asynchronous communication in networks of communicating processes. We formalize several notions of asynchrony independently of any particular concurrent process paradigm. A process is asynchronous if its input and/or output is filtered through a communication medium, such as a buffer or a queue, possibly with feedback. We prove that the behavior of asynchronous processes can be equivalently characterized by first-order axioms.

Comments University of Pennsylvania Institute for Research in Cognitive Science Technical Report No. IRCS-97-17.

This thesis or dissertation is available at ScholarlyCommons: https://repository.upenn.edu/ircs_reports/88 , Institute for Research in Cognitive Science

Functionality, Polymorphism, and Concurrency: A Mathematical Investigation of Programming Paradigms

Peter Selinger

University of Pennsylvania 3401 Walnut Street, Suite 400A Philadelphia, PA 19104-6228

October 1997

Site of the NSF Science and Technology Center for Research in Cognitive Science

IRCS Report 97--17 FUNCTIONALITY, POLYMORPHISM, AND CONCURRENCY:

A MATHEMATICAL INVESTIGATION OF PROGRAMMING PARADIGMS

Peter Selinger

A Dissertation in Mathematics

Presented to the Faculties of the University of Pennsylvania in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy

1997

Supervisor of Dissertation

Graduate Group Chairperson ii COPYRIGHT

PETER SELINGER

1997 iv In Memory of Moez Alimohamed 1967–1994

v Acknowledgments

This research was supported by graduate fellowships from the Institute for Research in Cognitive Science and from the School of Arts and Sciences at the University of Pennsylvania, and by an Alfred P. Sloan Doctoral Dissertation Fellowship. Some of the results in Chapters 3 and 4 were announced in a paper that appeared in the Proceedings of the Eleventh Annual IEEE Symposium on Logic in Computer Science [57]. Parts of Chapter 6 are scheduled to appear in the Proceedings of CONCUR ’97 [58]. Part of this research was done while I was visiting the Isaac Newton Institute at the University of Cambridge as an affiliated participant of the Semantics of Computation Program in the Fall of 1995. I am grateful to Gordon Plotkin for introducing me to the problem of partial orders on term models, and for many stimulating and enjoyable discussions on the lambda calculus. He has kindly consented to the inclusion of his previously unpublished proof of Theorem 3.16, as well as the material in Section 3.4, some of which resulted from his discussions with Alex Simpson. I would also like to thank Peter Freyd, Furio Honsell, Martin Hyland, Catuscia Palamidessi, Benjamin Pierce, Simona Ronchi, Davide Sangiorgi, , Phil Scott, and Glynn Winskel. They all have contributed valuable comments on parts of this work at various stages of its completion. Thanks to Peter Freyd, David Harbater, Andre Scedrov, and Scott Weinstein for serving on my Ph.D. com- mittee. Thanks to the staff at the Math Department at the University of Pennsylvania for helping me time and again with the administrative aspects of being a graduate student. Thanks to Jeny Carden, for her love and support. Finally, I would like to express my special gratitude to my advisor Andre Scedrov for his guidance, support, candid criticism, and for his faith in my ability to complete this task.

Philadelphia, June 1997

vi ABSTRACT

FUNCTIONALITY, POLYMORPHISM, AND CONCURRENCY:

A MATHEMATICAL INVESTIGATION OF PROGRAMMING PARADIGMS

Peter Selinger

Andre Scedrov

The search for mathematical models of computational phenomena often leads to problems that are of inde- pendent mathematical interest. Selected problems of this kind are investigated in this thesis. First, we study models of the untyped lambda calculus. Although many familiar models are constructed by order-theoretic methods, it is also known that there are some models of the lambda calculus that cannot be non-trivially

ordered. We show that the standard open and closed term algebras are unorderable. We characterize the ab- T solutely unorderable T-algebras in any algebraic variety . Here an algebra is called absolutely unorderable if it cannot be embedded in an orderable algebra. We then introduce a notion of finite models for the lambda calculus, contrasting the known fact that models of the lambda calculus, in the traditional sense, are always non-recursive. Our finite models are based on Plotkin’s syntactical models of reduction. We give a method for constructing such models, and some examples that show how finite models can yield useful information about terms. Next, we study models of typed lambda calculi. Models of the polymorphic lambda calculus can be divided into environment-style models, such as Bruce and Meyer’s non-strict set-theoretic models, and categorical models, such as Seely’s interpretation in PL-categories. Reynolds has shown that there are no set-theoretic strict models. Following a different approach, we investigate a notion of non-strict categorical models. These provide a uniform framework in which one can describe various classes of non-strict models, including set-theoretic models with or without empty types, and Kripke-style models. We show that com- pleteness theorems correspond to categorical representation theorems, and we reprove a completeness result by Meyer et al. on set-theoretic models of the simply-typed lambda calculus with possibly empty types. Fi- nally, we study properties of asynchronous communication in networks of communicating processes. We formalize several notions of asynchrony independently of any particular concurrent process paradigm. A process is asynchronous if its input and/or output is filtered through a communication medium, such as a buffer or a queue, possibly with feedback. We prove that the behavior of asynchronous processes can be equivalently characterized by first-order axioms.

vii viii Contents

Introduction 1

1 Preliminaries 5 1.1 Basic theory ...... 5 1.1.1 Categories ...... 5 1.1.2 Functors ...... 6 1.1.3 Natural transformations ...... 7 1.1.4 Adjunctions ...... 7 1.1.5 Limits and colimits ...... 7 1.1.6 Cartesian-closed categories ...... 8 1.2 Basic ...... 10 1.2.1 Preorders and posets ...... 10 1.2.2 Complete partial orders ...... 11 1.2.3 Bounded complete partial orders ...... 11 1.2.4 Stability ...... 11

1.2.5 Domain equations ...... 12 D

1.2.6 The -construction ...... 13 1.3 Basic universal algebra ...... 13

1.3.1 -algebras ...... 13 1.3.2 Term algebras ...... 14 1.3.3 Algebraic varieties ...... 14 1.3.4 Indeterminates ...... 15 1.3.5 Ordered algebras ...... 16 1.3.6 Dcpo-algebras ...... 17

2 The Lambda Calculus is Algebraic 19 2.1 The lambda calculus ...... 20 2.1.1 Lambda conversion ...... 20 2.1.2 Lambda reduction and consistency ...... 21 2.2 Combinatory models of the lambda calculus ...... 22 2.2.1 Combinatory algebras and combinatory logic ...... 22 2.2.2 The derived lambda abstractor ...... 23 2.2.3 The local interpretation of lambda terms ...... 23 2.2.4 Lambda algebras ...... 24

2.3 Lambda algebras and indeterminates ...... 25

x 2.3.1 A characterization of A for lambda algebras ...... 25 2.3.2 The absolute interpretation ...... 26 2.3.3 Soundness and completeness for lambda algebras ...... 28 2.4 Lambda theories and lambda algebras form equivalent categories ...... 28 2.5 Lambda models ...... 29

ix 2.6 Models of the lambda--calculus ...... 30 2.6.1 Curry algebras ...... 30 2.6.2 Extensional models ...... 30 2.7 Lambda algebras and categorical models ...... 30 2.7.1 Reflexive ccc models ...... 30 2.7.2 Reflexive ccc models and lambda algebras ...... 31

3 Unorderability 35 3.1 Lambda terms cannot be ordered ...... 36 3.1.1 Plotkin’s unorderable algebra: Separability ...... 36 3.1.2 The standard term algebras are unorderable ...... 36 3.2 The Topological Completeness Problem ...... 37 3.3 A characterization of absolutely unorderable algebras ...... 39 3.3.1 Absolutely unorderable algebras and generalized Mal’cev operators ...... 39 3.3.2 An application to ordered algebras and dcpo-algebras ...... 40 3.4 Absolutely unorderable combinatory algebras ...... 41 3.5 Relating different notions of unorderability ...... 43 3.5.1 Local notions ...... 43 3.5.2 Absolute notions ...... 44

4 Finite Lambda Models 47 4.1 Models of reduction ...... 47 4.1.1 Syntactical models of reduction ...... 47 4.1.2 Categorical models of reduction ...... 48

4.1.3 Models of -reduction: Order-extensionality ...... 49 4.2 Tree models ...... 49 4.2.1 Recapturing convertibility ...... 49 4.2.2 A method for constructing models ...... 50 4.3 Partial models ...... 51

4.4 Examples ...... 52

4.4.1 A class of finite models to distinguish the terms n ...... 52 4.4.2 A non-trivial 3-element model ...... 53

4.5 Completeness ...... 54 D

4.6 Relating models of reduction to -models ...... 54

5 Henkin Representations, Polymorphism, and Empty Types 57 5.1 Henkin representations of cartesian-closed categories ...... 58 5.1.1 Henkin representations ...... 58 5.1.2 Henkin representations and well-pointed ccc’s ...... 59 5.1.3 Freely adjoining arrows to a ccc ...... 60 5.1.4 Henkin representation theorems ...... 62 5.2 The interpretation of the simply-typed lambda calculus ...... 64 5.2.1 The simply-typed lambda calculus ...... 64 5.2.2 Strict interpretation in a cartesian-closed category ...... 65 5.2.3 The cartesian-closed category associated to a theory ...... 67 5.2.4 Henkin representations of a free ccc ...... 67 5.2.5 The non-strict interpretation of the simply-typed lambda calculus ...... 67 5.3 From Henkin representation theorems to completeness theorems ...... 68 5.3.1 The problem with empty types ...... 68 5.3.2 A categorical analysis of the rule (non-empty)...... 69 5.3.3 Set-theoretic models with non-empty types ...... 69 5.3.4 Set-theoretic models with empty types ...... 69

x 5.3.5 Kripke lambda models ...... 72 5.3.6 A remark on the principal model property ...... 72 5.4 Henkin representations of PL-categories ...... 72 5.4.1 PL-categories ...... 72 5.4.2 Henkin-PL-representations ...... 74 5.4.3 Standard structures ...... 75 5.4.4 Freely adjoining arrows to the base of a PL-category ...... 76 5.4.5 Henkin-PL-representation theorems ...... 77 5.5 The interpretation of the polymorphic lambda calculus ...... 78 5.5.1 The polymorphic lambda calculus ...... 78 5.5.2 Strict interpretation in a PL-category ...... 79 5.5.3 The PL-category associated to a theory ...... 81 5.5.4 The non-strict interpretation of the polymorphic lambda calculus ...... 81 5.6 From Henkin-PL-representation theorems to polymorphic completeness theorems ...... 82 5.6.1 Set-theoretic models with non-empty types ...... 82 5.6.2 Polymorphic Kripke models ...... 82

6 First-Order Axioms for Asynchrony 83 6.1 An elementary definition of asynchrony ...... 83 6.1.1 Labeled transition systems and bisimulation ...... 84 6.1.2 Input, output and sequential composition ...... 85 6.1.3 Buffers and queues ...... 87 6.1.4 Notions of asynchrony ...... 87 6.1.5 Examples ...... 88 6.2 First-order axioms for asynchrony ...... 89 6.2.1 Out-buffered agents ...... 89 6.2.2 In-buffered agents ...... 92 6.2.3 Out-queued and in-queued agents ...... 93 6.3 More agent constructors and asynchrony with feedback ...... 93 6.3.1 Some operations on agents ...... 93 6.3.2 Asynchrony with feedback ...... 94 6.4 Example: Asynchronous CCS ...... 96 6.5 Example: The core join calculus ...... 99 6.6 Other characterizations of asynchrony ...... 100 6.6.1 Out-buffered agents ...... 100 6.6.2 In-buffered agents ...... 102 6.6.3 Out-queued and in-queued agents ...... 104

xi xii List of Tables

1.1 Some posets ...... 10

1.2 Equational rules for -algebras ...... 15

1.3 Inequational rules for -algebras ...... 16

2.1 The axioms and rules of the lambda calculus ...... 20 2.2 Reduction rules of the lambda calculus ...... 21 2.3 The axioms and rules of combinatory logic ...... 22

4.1 Multiplication table for a partial model ...... 53

c b a k c b a 4.2 Values for and ...... 54

5.1 Typing rules for the simply-typed lambda calculus ...... 64 5.2 Equational rules for the simply-typed lambda calculus ...... 65 5.3 Rules for the simply-typed lambda calculus with emptiness assertions ...... 70 5.4 Typing rules for the polymorphic lambda calculus ...... 78 5.5 Equational rules for the polymorphic lambda calculus ...... 78

6.1 First-order axioms for out-buffered agents ...... 89 6.2 First-order axioms for in-buffered agents ...... 90 6.3 First-order axioms for out-queued agents ...... 90 6.4 First-order axioms for in-queued agents ...... 90 6.5 First-order axioms for out-buffered agents with feedback ...... 95 6.6 Transitions rules for asynchronous CCS ...... 97 6.7 Transitions rules for the core join calculus ...... 99 6.8 Second-order axioms for out-buffered agents ...... 101 6.9 Second-order axioms for in-buffered agents ...... 103 6.10 Second-order axioms for out-queued agents ...... 103 6.11 Second-order axioms for in-queued agents ...... 103

xiii Introduction

The central aim in giving mathematical meaning to computer programs is to represent computational objects, such as procedures, data types, or communication channels, by mathematical objects, such as functions, sets, or more generally, points in suitable mathematical spaces. Often, one begins with an idealized programming language, such as the lambda calculus or Milner’s calculus of communicating systems, and then seeks to find a mathematical model that reflects the relevant computational properties. The search for such models is guided by computational as well as mathematical intuitions, and it often leads to problems that are of independent mathematical interest. Some selected problems of this kind are investigated in this dissertation. The first part of this thesis is devoted to the model theory of the untyped lambda calculus. D. Scott dis- covered in the late 1960’s that models of the untyped lambda calculus can be constructed by a combination of order-theoretic and topological methods. Scott’s methods have been widely studied and adapted to numerous situations, and today one can choose from a wide array of model constructions that are based on Scott’s prin- ciples. On the other hand, there are results that indicate that Scott’s methods may not in general be complete: Honsell and Ronchi Della Rocca [27] have shown that there exists a lambda theory that does not arise as the theory of a reflexive model in the cartesian-closed category of complete partial orders and Scott-continuous functions. Moreover, there are properties that one may desire in a model, but that are incompatible with the presence of a partial order: for instance, Plotkin [50] has recently shown that there exists an extensional

lambda algebra which is finitely separable. By definition, a lambda algebra X is finitely separable if for every

A X f A X X f x f x

finite subset and for every function , there exists an element f such that

X for all x . It is not hard to see that a finitely separable algebra cannot be non-trivially partially ordered in a way such that the order is compatible with the algebra structure.

In general, we define a lambda algebra X to be unorderable if there does not exist a non-trivial partial

order on X for which the application operation is monotone. Our first main result is the following: The

standard open and closed term algebras of the - and -calculi are unorderable. Recall that the standard term algebras are just made up from lambda terms, taken up to -or -equivalence. The unorderability of the standard term algebras is a surprising fact, because the algebras that were previously known to be unorderable, such as Plotkin’s finitely separable algebra, require a much more delicate syntactic construction.

As a consequence of this result, it follows that if a partially ordered model of the untyped lambda calculus is complete for one of the theories or , then the denotations of closed terms in that model are pairwise incomparable, i.e. the term denotations form an anti-chain. Closely related to the question of unorderability is the question of order-incompleteness: does there exist a lambda theory that does not arise as the theory of a non-trivially partially ordered model? Or, expressed in terms of algebras: does there exist a lambda algebra which cannot be embedded in an orderable one? We call such an algebra absolutely unorderable. The concept of absolute unorderability can be formulated

in any algebraic variety T, and our second main result is a theorem in universal algebra: In any algebraic

A n

variety T, an algebra is absolutely unorderable if and only if, for some , there exist polynomials

M M Ax x x t M t u u M t t u M t u u

n i i

such that the equations , for

i n M t t u u Au t M M

n , and n hold in . Operators satisfying this condition are called generalized Mal’cev operators. Such operators were first used by Hagemann and Mitschke [25] to

characterize varieties with n-permutable congruences. The connection to unorderability was first noticed by

Taylor [63, 11], who proved that algebras in a variety with n-permutable congruences are unorderable; the converse is a new result.

1

As a consequence, the question of order-incompleteness for the untyped lambda calculus has been reduced

n M M n to the question whether it is consistent, for some , to add generalized Mal’cev operators

to the lambda calculus. It was proved by Plotkin and Simpson that a Mal’cev operator is inconsistent with the

n lambda calculus for n . Later, Plotkin and myself showed that it is also inconsistent for . In the remaining cases, the answer is not known. We continue our investigation of models of the untyped lambda calculus by introducing a notion of finite lambda models. These models provide a tool for predicting the evaluation behavior of a lambda term by finitary means. This yields a novel proof method for proving inequalities of untyped lambda terms. Finite models differ from traditional models of the untyped lambda calculus, which are always infinite and in fact

never even recursive, in that they are models of reduction, rather than models of conversion. This means that

N M N

they are equipped with a partial order and a soundness property of the form M , where

denotes either -or -reduction. Models of reduction were considered by several authors [23, 30, 49], and we use a formulation which was given by Plotkin [49] in the spirit of the familiar syntactical lambda models [5]. We focus on practical methods of constructing such models, and we show in two examples that, despite their simplicity, finite models can yield useful information about lambda terms. The second part of this thesis is devoted to models of the simply-typed and the polymorphic lambda cal- culus. The models in the literature follow one of two basic designs: set-theoretic environment-style models, such as Henkin models for the simply-typed lambda calculus [21] or Bruce-Meyer models for polymorphism [10], and categorical models, such as the interpretation of the simply-typed calculus in a cartesian closed

category [33] or of the polymorphic calculus in a PL-category [56]. Environment-style models are typically

non-strict, in the sense that a function type is interpreted as a subset of the set of functions from to

. On the other hand, categorical models are always strict. Reynolds has shown that there are no strict set-theoretic models of the polymorphic lambda calculus [52]. Here, we take the opposite approach and consider non-strict categorical models. This generalizes both environment-style models and strict categorical models. The central concept is that of a Henkin rep-

resentation: a functor H between cartesian-closed categories that preserves finite products, such that for all

A H A

H B H B objects A B , the canonical morphism is monic. Henkin representations provide a uniform framework in which one can describe various classes of non-strict models, including set-theoretic models with possibly empty types [39], set-theoretic models with non-empty types [21], and Kripke-style models [42]. We show that completeness theorems for each of these classes of models correspond naturally to categorical Henkin representation theorems. One such Henkin representation theorem characterizes those

cartesian-closed categories that can be Henkin-embedded in the category of sets: we show that this is the case

A if and only if every object A is either partially initial, or the canonical morphism is epic. This allows a new proof of a result by Meyer et al. [39] on the semantic consequences that hold in set-theoretic models of the simply-typed lambda calculus with possibly empty types. The last part of this dissertation is concerned with the study of properties of asynchronous communica- tion in networks of communicating processes. Informally, communication in such a network is said to be synchronous if message transmission is instantaneous, such that sender and receiver must be available at the same time in order to communicate. It is asynchronous if messages are assumed to travel through a communi- cation medium with possible delay, such that the sender cannot be certain when a message has been received. Asynchronous communication is often studied in the framework of a concurrent process calculus such as the

asynchronous -calculus [26, 9] or the join calculus [17, 18]. Here, we study asynchronous communication in general, independently of any particular process paradigm. We model processes by labeled transition sys- tems with input and output. These transition systems are similar to the input/output automata by Lynch and

Stark [35], but our presentation is more category-theoretic in a style that resembles Abramsky’s interaction

T

categories [1, 2]. In particular, we adopt Abramsky’s notation S for the sequential composition of two T processes, by which we mean the process obtained by connecting the output of S to the input of . First, we formalize the intuitive notion of asynchrony in elementary terms: we define a process to be asynchronous if its input and/or output is filtered through an explicitly modeled communication medium,

such as a buffer or a queue, possibly with feedback. For instance, we call a process out-buffered if it is,

B B up to weak bisimulation, of the form S , where is a special buffer process. Our main result about asynchronous processes is a characterization of various different such notions of asynchrony in terms of

2 first- and second-order axioms. These axioms refer directly to the behavior of a process, without mentioning buffers or queues explicitly. For instance, a process is out-buffered if and only if it is weakly bisimilar to a process satisfying three properties which we call output-commutativity, output-confluence, and output- determinacy. We illustrate these concepts by applying them to an asynchronous version of Milner’s CCS and to the core join calculus. This thesis is organized as follows: Chapter 1 is a summary of standard concepts of category theory, domain theory, and universal algebra, which are needed throughout the thesis. Chapter 2 is an introduction to the untyped lambda calculus and its combinatory models. In Chapter 3, we investigate unorderable and absolutely unorderable models of the untyped lambda calculus. Chapter 4 is devoted to finite lambda models. In Chapter 5, we study Henkin representation theorems and their applications to non-strict models of the simply-typed and polymorphic lambda calculi. In Chapter 6, we investigate properties of asynchronous communication.

3 4 Chapter 1

Preliminaries

We begin by gathering some basic concepts from category theory, domain theory, and universal algebra. This is mostly for the purpose of fixing terminology and notation for the later chapters of this thesis, and to provide a brief reference. We do not give any proofs in this chapter. For a more complete and detailed introduction to category theory, see e.g. [20] or [36]. For an introduction to domain theory, see e.g. [3] or [47]. For an introduction to universal algebra, see e.g. [24] or [13].

1.1 Basic category theory

1.1.1 Categories

hjCj id i jCj A B

A category C consists of a class of objects, together with a set of mor-

jCj

phisms for each pair of objects A B , and together with operations

id A A

A

B C A B A C

AB C

jCj

for all A B C , satisfying

id f f f id f A B A

B for

h g f h g f f A B g B C h C D

for , , .

id id g f

We will often omit the subscripts on and . A morphism A is called an identity morphism, and is

g A B A B

called the composition of f and . The set is called the hom-set of and . If we want to make

A B f A B

the category unambiguous, we also write hom-sets as C . A morphism is also written

f

A B A B A B f

f or , and we call the source or the domain and the target or the codomain of .

A B g B C g f

If f and , then we sometimes write the composition in diagrammatic order as

f g

B C f g A or as .

Example 1.1. The category S of sets has sets as its objects, and functions as its morphisms. Notice that the collection of all sets is not itself a set; this is why, in the definition of a category, one allows the collection of objects to be a proper class. A category is said to be small if the collection of its objects is a set.

A category is discrete if its only morphisms are identity morphisms. If C is any category, then its dual

op op op

jC j jCj C A B CB A

category C is defined by and , i.e. by reversing the direction of all

D C D jC Dj jCjjDj

morphisms. If C and are categories, then their product is defined by and

hA A i hB B iA B A B , with the pointwise identities and composition.

5

A diagram

f

A B

g

h

C D k

is used as a notation for the statement

A B g B D h A C k C D g f k h

f and and and and , f g h k and similarly for other diagrams. Note that this notation is not meant to imply that A B C D or are different. In the diagrammatic notation, we may also omit the names of the objects. Of course, it is then still understood that the appropriate morphisms are composable. The symbol in a diagram removes exactly

one equation, such that

g

f

h

g f h g h means f . This diagram does not say whether . Diagrams are just a notation for ordinary mathematical statements, and we may use them together with logical symbols, quantifiers etc.

Example 1.2. A morphism f is said to be monic or a monomorphism if

g

f

g h g h h

Dually, f is said to be epic or an epimorphism if

g

f

g h g h h

Also, f is said to be iso or an isomorphism if

id

g

g

g

f

id

g g f f

If f is an isomorphism, then is uniquely determined. is called the inverse of and it is denoted by .

A B A B

If there is an isomorphism f , then and are said to be isomorphic objects. We sometimes write

A B f A B f A B

f for a monomorphism, for an epimorphism, and for an isomorphism.

f A B g f id f g

Notice that if has a left inverse A , then is a monic, called a split monic, and is an

f

i

A B

iI

epic, called a split epic. A collection of morphisms i with the same source is called collectively

g h C A f g f h i I g h i monic or a monic cone if for all , whenever i for all , then .

1.1.2 Functors

D F C D F jCj jDj

If C and are categories, then a (covariant) functor is a map of objects,

CA B DFAFB

together with a map F for each hom-set, such that

F id id

A FA

F g f Fg Ff

op

F C

The category of small categories, together with functors between them, is denoted C at. A functor

C D D is also called a contravariant functor from to .

6

op

C C S A B

Example 1.3. For any category C, there is a functor Hom , which is defined by Hom

A B f gxg x f A jCj A C S A C and Hom . For any object , the functor is called the -

op

AC S A th (covariant) representable functor. Dually, the functor is called the -th contravariant

representable functor.

C D F A B FAFB F F

A functor F is full if each is onto. is an embedding if each

A B FAFB

is one-to-one. We say F is faithful if it is an embedding and it reflects isomorphisms, f

i.e., whenever Ff is an isomorphism, then so is .

D jCjjDj A B jCj CA B DA B

A category C is a subcategory of if , and for all , . The

C D IA A If f C

corresponding inclusion functor I , with and , is always an embedding. is said I to be a full subcategory if I is full, and a faithful subcategory if is faithful.

1.1.3 Natural transformations

F G F G C D

A

jCj

A natural transformation between functors is a family A of morphisms

FA GA f A B

A such that for all ,

A

FA GA

Ff Gf

FB GB

B

C D C D C

There is a category whose objects are functors F , for fixed and (say, is small). The

F id F F

morphisms are natural transformations. For any functor , the identity natural transformation F

id id F G G H

A FA

is defined by F . Composition of natural transformations and is defined

C

D A

by A . The resulting category is written , and it is called a functor category.

A

F G C D F G

Two functors are said to be naturally isomorphic, in symbols , if there are natural

F G G F id id F

transformations and such that G and .

F A GA F A B GA B AB

We sometimes write A , etc. to express that ,asa

F A GA

transformation of functors, is natural in the indicated arguments. Similarly, we write A etc. to

F G AF A GA express that and are naturally isomorphic. Notice that this is different from writing ;

the latter statement expresses only a condition on objects, and not on morphisms.

D F C D G D C G F

An equivalence of categories C and is a pair of functors and such that

G C D and F are naturally isomorphic to the identity functors on and , respectively.

1.1.4 Adjunctions

C D G D C

An adjunction between functors F and is a natural isomorphism

A GB FAB

AB

G F a G F a G

In this case, the pair of functors F and is called an adjoint pair, and we write , or simply .

F G G F u id G F

is a left adjoint of and is a right adjoint of . The unit C of an adjunction is the

u id A GF A c F G id

FA D

natural transformation given by A , and the co-unit is defined

u c F G dually. Each of the entities , and determines the two others uniquely. Moreover, and determine each other up to natural isomorphism.

1.1.5 Limits and colimits

C C I I C

Let I be a small category, a category. A diagram in modeled on is a functor .Acone over

hD d i D d D i

i i

jI j a diagram is a pair i , consisting of an object and a family of morphisms for

7

jI j f i j I

each i , such that for each in ,

f

i j

d d

i j

D

hE e i hD d i f E D

i i

jI j ijI j

A morphism between cones i and over a diagram is an arrow such

e d f i jI j hD d i

i i i

jI j

that for all . A cone i is called limiting or a limit if it is terminal among

hE e i f E D

i

jI j

cones over , i.e. from any other cone i , there is a unique morphism of cones .

D e

Sometimes, we also call the object a limit. The morphisms i of a limiting cone are called limiting morphisms. Limiting cones, if they exist at all, are uniquely determined up to isomorphism. Limiting cones are collectively monic. Cocones, colimits and colimiting morphisms are defined dually. Some special limits are of interest: A limit of a diagram that is modeled on a discrete category is called a product. The limiting morphisms of a product are called projections. A limit of the empty diagram is called

a terminator or a terminal object. A limit of a diagram that is modeled on the category

is called an equalizer. A limit of a diagram that is modeled on the category

is called a pullback. The dual concepts are coproduct, coterminator or initial object, co-equalizer, and pushout. Definition. A category is complete if every small diagram has a limit, and cocomplete if every small diagram has a colimit. Proposition 1.4. A category is complete iff it has products and equalizers. It is cocomplete iff it has coprod- ucts and co-equalizers.

1.1.6 Cartesian-closed categories

A A B Recall that an object B is a terminator if for all , is a singleton. A terminator is unique up to

isomorphism. If we have chosen a terminator in a category, we denote it by . The unique morphism in

e

A

is then denoted A .

A diagram

P

f g

B C

A B r A C

is called a (binary) product diagram if for every pair of morphisms q and , there exists

A P f s q g s r

a unique s such that and . This is the case if and only if

A P A B A C

A

id hf gi B

via a natural isomorphism that relates P to the pair . Product diagrams are determined (for fixed

B C and C ) uniquely up to isomorphism. If we have chosen, for any and , a product diagram, then we denote

8

it by

B C

B C

A B C s q A B s r A C

The unique morphism s such that and is then denoted

q ri q r hq ri b B B c C C

h . The operation that takes and to is called pairing.If and , then we

c hb c i B B C C F B C B C denote by b the morphism . This makes into a functor.

In a category with chosen products, a diagram

f

D B

C

A B C h A D is called an exponential diagram if for every morphism g there is a unique such

that

f

D B

C

hid

B

g

A B

This is the case if and only if

A D A B C

A

id f B C

via a natural isomorphism that relates D to . For given and , exponential diagrams are determined C uniquely up to isomorphism. If we have chosen, for any B and , an exponential diagram, then we denote it

by

B

C

C B

B

h A C h id g A B C g

The unique morphism such that B is then denoted . The

g g h h h id B

operation that takes into is called . The inverse operation, which takes to ,

b

b B B c C C c c id B b

is called uncurrying.If and , then denotes the morphism C

B

B B

C C B C C . This makes F into a functor, contravariant in the first argument and covariant in

the second.

B

A A h A C g A B C

Remark. The following identities are often useful, where a , , :

B

g a id g a A C

B

B B

id C C

h a h a id A B C

B

B

id C B C

Definition. A cartesian-closed category (ccc) is a category with chosen terminator, chosen binary product diagrams and chosen exponential diagrams. A ccc-representation is a functor that preserves the chosen terminator, product and exponential diagrams. A functor that preserves ccc structure up to isomorphism is called a ccc-representation up to isomorphism.

op

C S Example 1.5. For any small category C, the functor category is cartesian-closed. The Yoneda embed- op

C op

C S A AC S

ding Y maps an object to the functor . The Yoneda embedding is full and Y faithful, and if C is cartesian-closed, then is a ccc-representation up to isomorphism. The functor category

op

C C S is called the category of presheaves over .

9 Table 1.1: Some posets

.

.

n

n

.

.

(1) The flat natural numbers (2) The ordinal

1.2 Basic domain theory

We gather some basic domain-theoretic concepts. For a more detailed introduction, consult e.g. the texts by Abramsky and Jung [3] or Plotkin [47].

1.2.1 Preorders and posets D

A binary relation on a set is called a preorder if

x D x x

1. (Reflexivity).

x y z D x y y z x z 2. and (Transitivity).

A preorder is a partial order if, in addition,

x y D x y y x x y

3. and (Antisymmetry).

D i f D E

A h is also called a poset. A function between posets is monotone

y fx fy x y D

if x implies , for all . We denote the category of posets and monotone functions by

D D

POSET. It is cartesian-closed. The exponential E is given by the set of all monotone functions from to

f g x D fx gx

E , with the pointwise order, if for all , .

D A fy D jx Ay xg A

For A , let be the set . A set is called downward closed or a

A A fxg x fxg A x

downdeal if A .If is a singleton, we also write . The sets and are defined

A A x A fxg x A

dually. An element x is said to be minimal in if . Also, is said to be a minimum

A x

or a least element of A if . Maximal elements and greatest elements are defined dually. An element

D A a b a A A

b is said to be an upper bound of if for all . If among the upper bounds of there is

W A

a least one, it is called the least upper bound, the join or the supremum of A, and it is denoted by or

W

x y fx y g

x. We also write for the supremum of , if it exists. Lower bounds are defined dually, and

xA

V D a greatest lower bound, denoted A, is also called a meet or an infimum. A poset is called a lattice if it

has finite suprema and infima, and a if it has arbitrary suprema and infima.

D i D a A poset h is pointed if it has a least element . is flat if it is pointed and if all elements

are maximal. An example of a flat poset are the “flat natural numbers”, shown in Table 1.1(1). Two elements

D x y z D x z y z

x y are called compatible, in symbols , if there exists with and . Notice that

two elements in a flat poset are compatible iff and of them is .

10

D i

Remark. Any poset h can itself be regarded as a category with hom-sets

x y

fg if

D x y

else.

Under this interpretation, a least element is just an initial object, suprema are colimits, functors are mono-

D E g E D

tone maps, and an adjunction is a pair of monotone maps f and such that

fx y x gy

1.2.2 Complete partial orders

x y I z I x y z

A poset I is directed if it is non-empty and if for all , there exists with . A poset

D i

h is directed complete if every directed subset has a supremum. A directed complete poset is also called

I f D E x

B BB

a dcpo. Directed suprema are also denoted by B or . A function between dcpo’s is called

xI Scott-continuous if it is monotone and it preserves directed suprema. We denote the category of dcpo’s and

Scott-continuous functions by DCPO. The full subcategory of pointed dcpo’s is denoted by DCPO . Both D

these categories are cartesian-closed. The exponential E is given by the set of all Scott-continuous functions

D

E E

from D to with the pointwise order. Directed suprema in can be computed pointwise, i.e.

f x f x

i i

B B

B B

i i

x y I x y x y A poset I is linearly ordered or a chain if for all , either or . An example of a

linearly ordered set is the ordinal , which is the set of natural numbers with their natural order, as shown in

hD i

Table 1.1(2). A set I which is isomorphic to is called an -chain. A poset is -complete if every

I D D

-chain has a supremum in .An -complete poset is also called a complete partial order or a cpo.

D E

A function f between cpo’s is called -continuous if it is monotone and it preserves suprema of

-chains. We denote the category of cpo’s and -continuous functions by CPO, and its full subcategory of

D E

pointed cpo’s by CPO . These categories are cartesian-closed, with the exponential given by the set of

D E all -continuous functions from to with the pointwise order, and pointwise suprema of -chains. Remark. The categories CPO and DCPO have similar properties. DCPO is a subcategory of CPO, but is neither full, nor is it a sub-ccc.

1.2.3 Bounded complete partial orders

D d D A d D

A subset A of a partially ordered set is called bounded if there is with . A cpo

D is bounded complete if every bounded subset A has a supremum. Bounded complete cpo’s and - continuous functions form a full sub-ccc CPObc of CPO. Notice that we do not require the morphisms to

preserve all bounded suprema. The categories CPObc, DCPObc, and DCPObc are defined analogously.

1.2.4 Stability

A cpo D is a meet cpo if it has bounded binary meets which act continuously. This means, that for every

D x ha bi a b x x

x , the set has binary meets, and the function is continuous on . A function

D E

f between meet cpo’s is stable if it preserves bounded binary meets. We denote the category

of meet cpo’s and stable maps by CPO , and its full subcategory of pointed meet cpo’s by CPO . These

D D categories are cartesian-closed too, and the exponential E is given by the set of all stable functions from

to E , not with the pointwise order, but with the Berry order or stable order:

f g x y D x y f xf y g x s

Directed suprema, as well as bounded infima, with respect to the Berry order are taken pointwise. The

cartesian-closed categories DCPO and DCPO are defined analogously. The theory of meet cpo’s and stable functions is due to Berry [7], who used them to study the semantics of sequential computations.

11

1.2.5 Domain equations

bc bc

D

Let be any one of the pointed categories DCPO , CPO , DCPO , CPO , DCPO ,orCPO . The

objects of D are called domains. One of the main features of these categories of domains is that they can be

used to solve domain equations, such as

D

D D

D

A solution to such an equation in a category D consists of an object , together with an isomorphism

D

D D . The ability to solve domain equations is an essential tool in mathematical programming semantics

to give meaning to a variety of programming language constructs, such as recursive data types. We are

D

D D particularly interested in solutions to the “classic” domain equation , whose solutions yield models

of the untyped lambda--calculus (see Section 2.7).

General methods for solving domain equations were pioneered by D. Scott [53], and further developed

D F D

by Smyth and Plotkin [61]. In general, a domain equation takes the form . Notice that, since the F right-hand-side may contain positive (covariant) as well as negative (contravariant) occurrences of D , will

not in general be a functor. The problem of mixed variance can be solved by passing from the category D to

e e e

D D D

a category D of embeddings. The objects of are the same as the objects of . The morphisms of are

D E D p E D D embeddings, where e in is called an embedding if there exists a projection in

such that

p e id e p id

D E

where the inequality is understood to be with respect to the relevant order on functions, i.e. the pointwise order

e

in the case of DCPO , CPO , etc., and the stable order in the case of DCPO or CPO . An embedding

p p e e p

is uniquely determined by its associated projection and vice versa. We write and . One also e

speaks of D as a category of embedding-projection pairs.

e e

D

An expanding sequence in D is a diagram modeled on the ordinal , i.e. a functor .In

D

nN

more concrete terms, an expanding sequence is a sequence n of objects, together with embeddings

e D D n m e id e e e p m n

n m mm D mn pm pn

nm for all , such that and , for all .

m

e

hD e i D

n nm nm

Proposition 1.6. Limit-colimit coincidence. Every expanding sequence n in has a

e

D D e D D hD e i D

n n n

colimit in , with colimiting morphisms n . Moreover, is also a colimit in , and

i i hD e hD e D D

n nm n

is a limit of n in . This is called the limit-colimit coincidence, and is also

n nm

called a bilimit.

hD e i n

Proposition 1.7. Characterization of bilimits. Let n be a cocone over the expanding sequence

e

hD e i D hD e i

n nm nm n n

n in . Then is a bilimit if and only if

id e e

D n

BB

n

n

e e

F D D hD e i

n nm nm

Definition. A functor is continuous if for every expanding sequence n

hD e i hFD Fe i hFD Fe i

n n n nm nm n n

with colimit n , the sequence has colimit .

D F D F

Proposition 1.8. Solution of domain equations. Consider a domain equation , where

e e

D D D e D F D

is a continuous functor. Starting with a domain and an embedding , let

D F D e F e n N D

n nn nn

n and for all . Let be the colimit of the expanding sequence

hD e i e e e n m D F D

n nm nm nm mm nn

n , where , for . Then .

F hFD Fe i hD e i

n nm nm n n nm nm

Proof. Since is continuous, the sequence n has

F D D D F D colimit . On the other hand, is a colimit of the same sequence, hence one gets .

The question remains how to identify a given functor as continuous. A useful criterion was given by Smyth

e D

and Plotkin [61], who observed that a continuous functor F on can be obtained from a locally continuous

D F functor F on . This works even if is of mixed variance.

12

op

D D D D D EE D

Definition. A functor F is locally continuous if for all objects ,

F D D D DE E DF D E F D E

if continuous as a map between hom-sets (with the pointwise order in the case of DCPO and CPO , and

the stable order in the case of DCPO and CPO ).

op

F D D

Proposition 1.9. Every locally continuous functor D gives rise to a continuous functor

e e

D D

F , defined by

F D F D D F eF e e

D

1.2.6 The -construction

D

D E E

The method of Proposition 1.8, applied to the locally continuous functor F , serves to solve

D

D D D the “classic” domain equation . This construction is due to D. Scott, and it is called the -

construction. D

Remark. Notice that the construction of a -model is dependent on some parameters, namely a category

D

D D e D D

, an object and an embedding . Hence, there is a whole class of such models. Among

D D

these, we distinguish the standard -model to be the one model constructed in CPO from the cpo

D

e D D

with two elements , and the embedding which maps to the constant function

and to the constant function.

1.3 Basic universal algebra

1.3.1 -algebras

hi N

An algebraic signature is a pair consisting of a set of function symbols and a map ,

k f ff j f k g k

assigning an arity to each . We let k be the set of -ary function

A hA I i A I f

symbols. A -algebra is a set together with an interpretation of every function symbol

f

A A jAj A A f

as a map from . We often write ,oreven for the underlying set of an algebra, and A or

I f A B jAjjBj

even f for the interpretation .Ahomomorphism of -algebras is a function

f a a A

k

such that for all k and all

f a a f a a

A k B k

We denote the category of -algebras and homomorphisms by -Alg. The category -Alg has all limits,

S

and the forgetful functor U -Alg preserves and reflects them. For instance, binary products are

jA Bj jAjjBj f ha b i ha b ihf a a f b b i

B k k A k B k

given by and A .A

A B jAjjBj f a a A

k

-algebra is a subalgebra of another -algebra if and for all k and ,

f a a f a a A B

k B k

A . The inclusion map of a subalgebra is a homomorphism.

A A A

Definition 1.10. A binary relation R on a -algebra is compatible if it is a subalgebra of . This

ha b iR i k hfa a fb b i R

i k k

is the case if and only if whenever i for , then , for each

k f A

-ary function symbol k .Acongruence on a -algebra is a compatible equivalence relation. If

A f x x

k

is a congruence, then the quotient algebra is a well-defined -algebra via A

f x x A A ker

k

A . The natural map is a homomorphism of -algebras. The kernel of a

A B A a a aa homomorphism is the congruence relation on defined by iff .

13

1.3.2 Term algebras

X x X c W X

Let be a set. For each , pick a distinct symbol x , which is not in . Let be the set of

fc j x X g

words (i.e.finite sequences) from the alphabet x .

X T W X

Definition. The set of -terms over is defined to be the smallest subset such that

x X f t T t T

k k

c T ft t T

x k

f t t

X k

Let be the set of -terms thus defined. It has a natural -algebra structure via

X

X ft t

X k . The algebra is called the -term algebra over .

Remark. We have represented terms as words from some alphabet. There are other possible choices; for

ft t f k

instance, one could represent a term as a labeled rooted tree with label at the root and with imme-

t t k diate subtrees . In general, we will not be too concerned here with the details of how to represent

syntax; rather, we will treat syntax as a primitive notion. Independently of which concrete representation for

X x c

X x terms one chooses, X , together with its natural map , is completely determined by

the following universal property:

B X B

Proposition 1.11. For any -algebra and any map , there is a unique homomorphism

B

X such that

X

X

B

U S F S F X

Equivalently, the forgetful functor -Alg has a left adjoint -Alg with X ,

X

and with X as the unit of the adjunction.

X B B

A map is also called a valuation in .If is the unique extension of to terms, then we often

t t t X

write instead of for the interpretation of a term . The defining equations for are

x x x

for a variable,

ft t f t t f

k A k k

for .

X fx x g t n

n X

If is a finite set of variables, then a term is also called a -ary operation in .We

t tx x b b B tb b

n n n

write .If are elements of a -algebra , then we sometimes write

t X B x b

i i for where .

1.3.3 Algebraic varieties

V ht si V

Fix a countable set of variables.A -equation is a pair of terms V . Equations are often

s A t s A j t s

written in the form t .A -algebra satisfies an equation , in symbols , if for all

A t s A j t s V A

homomorphisms V , . Equivalently, if for all valuations ,

t s

.

E A

Definition. Let be a signature, and let be a set of -equations. A -algebra that satisfies all equations

E E

in E is called a -algebra. The -algebras form a full subcategory of -Alg, which we denote

E T

by -Alg. Any full subcategory of -Alg that arises in this way is called an algebraic variety. The T

algebras of an algebraic variety T are also called -algebras.

T E T T

Let be an algebraic variety, defined by a signature and equations . We construct X , the free -algebra

X

over a set , as follows: On the term algebra X , consider the smallest congruence relation such that

hs tiE

V X

s t

14 Table 1.2: Equational rules for -algebras

(refl)

s s

f s t i k

i i

(cong) k

fs s ft t

s t

k k

(symm)

t s

s t V

(subst) V

st

t t u

(trans) s

s u

T T T X T

X X X Let X be the algebra . Then is a -algebra. Together with the natural map ,ithas

the universal property:

B X B

Proposition 1.12. For any T-algebra and any map , there is a unique homomorphism

T B

X such that

T

X

X

B

s t E s t s t

We say that a set of equations E entails an equation , in symbols eq ,if can be derived

E Ej s t A A j E

from the hypotheses by the rules in Table 1.2. We write -Alg if for all -algebras ,if ,

j s t then A .

Proposition 1.13. Soundness and Completeness for -algebras.

E s t Ej s t

eq if and only if -Alg

1.3.4 Indeterminates

E A T X

Let T be a variety with signature and equations . Let be a -algebra, and let be a set. Assume

jAj T

without loss of generality that X and are disjoint. Relative to the variety , the polynomial algebra

AX

AjX is defined as follows: On the term algebra j , consider the smallest congruence relation such

that

a f a a hs tiE

A k V

jAjX

c fc c s t

a a a



k

AX AX A AX

AjX

Let be the algebra j . Together with , consider the natural maps defined

ac X AX xc

x

by a , and defined by .

X T T B

Proposition 1.14. A is a -algebra with the following universal property: For any -algebra , any

A B T g X B

homomorphism f of -algebras, and any map , there is a unique homomorphism

AX B

h such that

AX

X A

h

g

f

B

A AX

Remark. The map is always an injection; we will often regard it as an inclusion. Notice that

AX Y X fx x g AX Ax x AX Y

n n

. In the case where is finite, we write .

X X The elements of A are called polynomials, and is called a set of indeterminates.

15

Table 1.3: Inequational rules for -algebras

f s t i k

i i

(refl) (cong) k

s s fs s ft t

k k

s t t u s t V

(trans) (subst) V

s u s t

1.3.5 Ordered algebras

jAj hA i

Let A be a -algebra, and let be a partial order on the carrier set . The pair is called an ordered

A

-algebra if the order is a compatible relation on in the sense of Definition 1.10. Concretely, this is the

k

f f A A A

case iff for each k , is a monotone map with respect to .Ahomomorphism of ordered

-algebras is a homomorphism of -algebras that is monotone. We denote the resulting category of ordered -algebras by -Ord.

Just as we considered sets of equations for -algebras, we may consider sets of inequations for ordered

V

-algebras. Recall that is a countable set of variables, and that V is the -term algebra. A -inequation

ht si t s hA i V

is a pair of terms V , often written . An ordered -algebra satisfies an inequation

t s A j t s A t s

, in symbols , if for all homomorphisms V of -algebras, .

A j t s VA t s

Equivalently, if for all valuations , .

I I

Definition. An ordered -algebra that satisfies a given set of inequations is called an ordered -

I I

algebra. The ordered -algebras form a full subcategory of -Ord, which we denote by -Ord.A

full subcategory O of -Ord that arises in this way is called an ordered variety.

I

Let O be an ordered variety, defined by a pair of a signature and a set of inequations. The free ordered

I P O P -algebra over a poset , denoted P , is constructed as follows: On the term algebra , consider the

smallest compatible preorder satisfying

hs tiI x y P

V P

s t c c

x y

O

P P

Let be the congruence on P , and let be the algebra , together with the partial order

x y x y O I

P

induced by via iff . Then is an ordered -algebra, and the natural map

P O

P is monotone. The following universal property holds:

I B P B

Proposition 1.15. For any ordered -algebra and any monotone map , there is a unique

I O B

homomorphism of ordered -algebras P such that

O

P

P

B

Rules for deriving inequations are given in Table 1.3. We say that a set of inequations I entails an inequation

t I s t s t I

s , in symbols ineq ,if can be derived from the hypotheses by these rules. We write

Ej s t A A j E A j s t

-Ord if for all ordered -algebras ,if , then .

Proposition 1.16. Soundness and Completeness for ordered -algebras.

E s t Ej s t

eq if and only if -Ord

s t I s t I t s We also sometimes write Iineq as an abbreviation for ineq and ineq .

16

1.3.6 Dcpo-algebras

hA i

Let be a signature. An ordered -algebra is called a -dcpo-algebra if the partial order is di-

k

f A A

rected complete, and if each interpreted operation A is Scott-continuous. A homomorphism of

-dcpo-algebras is a Scott-continuous homomorphism of ordered -algebras. We denote the resulting cate-

I

gory of -dcpo-algebras by -DCPO. Each set of inequations determines a full subcategory of -DCPO,

I

which we denote by -DCPO. We call such a subcategory a dcpo-variety.

I D I

Let D be a dcpo-variety, defined by . For every dcpo , there exists a free -dcpo-algebra

D D D D D D over , with an associated continuous map , satisfying the usual universal property. The

construction of the free dcpo-algebra is less trivial than in the case of ordered algebras, and it relies an Freyd’s D

Adjoint Functor Theorem. A proof of the existence of D can be found in Abramsky and Jung [3].

17 18 Chapter 2

The Lambda Calculus is Algebraic

The correspondence between Church’s untyped lambda calculus and Curry’s and Sch¬onfinkel’s combina- tory algebras is among the oldest known, and most esthetically pleasing, facts about the lambda calculus. However, the combinatory interpretation is also known to be somewhat imperfect, as Curry’s combinatory

abstraction operator does not in general satisfy the rule

M N

( )

xM xN

One usually resolves this problem by moving from the class of lambda algebras to the smaller class of

lambda models, which are, by definition, those lambda algebras in which ( ) holds. However, unlike the class of lambda algebras, the class of lambda models is not equationally definable. Therefore, it fails to enjoy some useful closure properties such as being closed under subalgebras.

In this chapter, we point out that the failure of the -rule, and the subsequent need for a non-equational class of models, is not due to the lambda calculus itself, but to the way free variables are usually interpreted in

these models. The usual interpretation of a lambda term is defined relative to a valuation of its free variables.

n

n A A Essentially, this amounts to interpreting a term M with free variables as a function . We argue

that it is more natural to model free variables as algebraic indeterminates and to interpret M as an element of

Ax x n a polynomial algebra . Based on this interpretation, we show that the class of lambda algebras

is sound and complete for arbitrary lambda theories. In particular, the notorious rule ( ) is sound with respect to this interpretation. This chapter is intended to serve as a self-contained, brief introduction to the lambda calculus and its combinatory models. We do not claim originality for the results in this chapter, which follow from known results in Barendregt’s book [5] and in the work of Koymans [31]. We do however hope to present these issues from a fresh point of view, particularly where the interpretation of free variables is concerned. Maybe this exposition will help to clarify the precise relationship between the lambda calculus, lambda algebras, and lambda models, which are sometimes confused in the literature. Lambda conversion and reduction are introduced in Section 2.1. Combinatory algebras and lambda al- gebras are defined in Section 2.2. Section 2.3 contains a detailed analysis of the behavior of indeterminates in the theory of lambda algebras, which leads to a streamlined interpretation of the lambda calculus. In Sec- tion 2.4, we show that the categories of lambda theories and of lambda algebras are equivalent. This, to some extent, justifies the slogan “the lambda calculus is algebraic”. Lambda models are the subject of Section 2.5,

and Section 2.6 is devoted to models of the lambda--calculus. Finally, in Section 2.7, we relate the different kinds of algebraic models to reflexive ccc models.

19

Table 2.1: The axioms and rules of the lambda calculus

M N N

(refl) (cong) M

M M MN M N

M N M N

(symm) ( )

N M xM xN

M N N P

(trans) ( )

M P xM N M Nx

2.1 The lambda calculus

The lambda calculus is a theory of functions as rules. Its two basic constructions are functional application,

fx f x xt

where denotes the application of a function to an argument , and functional abstraction, where t

denotes the function that maps x to . C

Definition. Let V be a countable set of variables, fixed throughout the rest of this chapter. Let be a set of

raw

constants. The set of raw lambda terms is defined to be the least set of terms such that

C

raw raw

c C M N x V M x V

C C

raw raw raw raw

x c MN xM

C C C C stu

Notation: We often use upper case letters MN, as well as lower case letters to denote lambda

MNP MNP

terms. We use xy to denote variables. To save parentheses, we write instead of ,

xM N xMN x x M x x M M

n n

instead of , and instead of . The set FV M

V of free variables of a raw lambda term is defined recursively:

xfxg c MN M N xM M nfxg

FV FV FV FV FV FV FV

M N M N

Variables that are not free are bound. We write if and are equal up to renaming of bound

raw

variables. The set C of lambda terms is then defined to be the set of -equivalence classes of C

raw terms. From now on, we will consider terms up to -equivalence without further mentioning it. A term

M Nx

with no free variables is closed. The set of closed terms is denoted . We write for the result of

C

x M x N

substituting N for in , taking appropriate care to ensure that neither nor any of the free variables of are bound in M . For a rigorous treatment of -equivalence and substitution, see e.g. [5].

2.1.1 Lambda conversion

The axioms and rules for deriving equations between lambda terms are shown in Table 2.1. If E is a set of

E M N M N E

equations, we write if is derivable from by using these rules. A lambda theory is a

T T M N M N T

set of closed equations that is closed under derivability, i.e. implies , for closed

N

M and . For a given set of constants, there is a unique smallest theory , called the pure theory or the

M N M N M N theory of -conversion. We also write as and we say that and are -convertible.

The lambda--calculus is the lambda calculus with the additional axiom

M

x FV

( )

xM x M

E M N M N E

We write if is derivable from a set of equations and the axiom ( ). A lambda

T

theory which is closed under is called a lambda- -theory. The unique smallest such theory is called

M N M N

the theory of -conversion, and it is denoted .If , then we write and we say

N that M and are -convertible.

20

Table 2.2: Reduction rules of the lambda calculus

M N N

(cong) M

M N

(refl) MN

M M

M N

( )

xM xN

N N P

(trans) M

M P

( )

xM N M Nx

Remark. The notion of theory given here is a slightly more liberal than the one given in [5], where the equations of a theory are not allowed to contain any constants. Notice that the lambda calculus is not given by a signature and equations in the sense of universal algebra. However, we will show in Section 2.3 that the lambda calculus is equivalent, in a suitable sense, to an algebraic theory.

2.1.2 Lambda reduction and consistency

When considering functions as rules, it is natural to think of the evaluation of a function applied to an argu-

ment as a dynamic process. This process is made explicit in the notions of -reduction and -reduction.

xM N M Nx

A term of the form is called a -redex, and it -reduces to . The relation is the

reflexive, transitive and contextual closure of this one-step -reduction. More precisely, is the smallest

relation on lambda terms satisfying the axioms and rules in Table 2.2. A term of the form xM x, where

M M

x FV , is called an -redex, and it -reduces to . The relation is the reflexive, transitive and contextual closure of the one-step - and -reductions, i.e., it is the smallest relation satisfying the axioms

and rules in Table 2.2 and also the axiom

M

x FV

( )

xM x M

M M M M

A term M is said to be in -normal form no subterm is a -redex, i.e. if . Similarly,

M M M M

M is in -normal form if it contains no -or -redex, i.e. if . Examples of

T xy x F xy y

terms in -normal form include the booleans and , as well as the Church numerals

xy x xy xy xy xxy

0 , 1 , 2 etc.; all of these except for 1 are also in -normal form.

a b a c

Definition. A binary relation is said to have the diamond property if whenever and ,

b d c d

then there exists d such that and . In diagrams:

a

a

c

c

b

b

d

Also, a relation is said to be Church-Rosser if the transitive closure has the diamond property.

Theorem 2.1 (Church, Rosser [12]). The relations and are Church-Rosser. This theorem was first proved by Church and Rosser in 1936 [12]. Since then, the proof has been adapted and streamlined in various ways by Tait, Martin-L¬of, Girard and others. One can find a proof in Barendregt’s book [5].

The Church-Rosser Theorem has several important consequences. As a first consequence, one proves that

M N P M P N P for each pair of -convertible lambda terms , there is a term with and . This

21

Table 2.3: The axioms and rules of combinatory logic

A B B

(refl) (cong) A

A A AB A B

B

(symm) A (k)

B A KAB A

B B C

(trans) A (s)

A C SAB C AC BC

M N

is easily shown by induction on the derivation of , using the rules in Table 2.1. This immediately

implies consistency of the lambda calculus:

M N M N M

Corollary 2.2. Consistency. If and are two different terms in -normal form, then .If

N M N

and are two different terms in -normal form, then .

2.2 Combinatory models of the lambda calculus

2.2.1 Combinatory algebras and combinatory logic

A A

Definition. An applicative structure is a set together with a binary operation. A combinatory

A ks k s x y z A

algebra is an applicative structure with distinguished elements and such that for all ,

kxy x sxy z xz yz

k x y f A B

Here we write kxy for , etc. A homomorphism of combinatory algebras is such that

k fs s f x y fx fy x y A

fk , and , for all .

T KS T

Example. The closed term algebra associated with a lambda theory T is , where is

C C

M N MN K xy x S xy z xz yz

the set of T -equivalence classes of closed terms, , and .

T KS

Similarly, the open term algebra is C .

Combinatory algebras form an algebraic variety. The corresponding algebraic language is combinatory logic:

V C C

let be a set of variables and a set of constants as before. The set C of combinatory terms or terms of

combinatory logic is defined to be the smallest set of terms such that

c C A B C x V

C

x C c C AB C K C S C

C C C C C

AB C

Again, we economize the use of parentheses by writing AB C instead of . A combinatory term is

closed if it contains no variables. The set of closed terms is denoted by C . A closed and constant-free term,

C S

i.e. a term that is made up only from K and , is also called a combinator. The axioms and rules for deriving

A B A B equations of combinatory logic are shown in Table 2.3. We write ECL if can be derived from

a set of equations E by these rules. A theory of combinatory logic is a set of closed equations that is closed

B A B

under derivability. The minimal theory is denoted CL, and we also write A CL instead of CL . Terms of combinatory logic can be interpreted in a combinatory algebra A, relative to a valuation of

variables an an interpretation I of constants. We call this the local interpretation to distinguish it from the

absolute interpretation that we will consider in Section 2.3.2.

I C A

Definition. Local interpretation of combinatory logic. Let A be a combinatory algebra, and let

A V A be an interpretation of constants in A.Avaluation of variables in is a map . The local

22

I

A A C

interpretation of a term C is defined inductively:

I I I I I I I

x x c I c K k S s AB A B

A B C I A B I j

For terms C , we say that the interpretation locally satisfies the equation , notation

I I

B A A B E j A B

A , if for all valuations in , . We write if for all combinatory algebras

CA

I C A I j E I j A B A and all interpretations ,if then .

Proposition 2.3. Soundness and Completeness for combinatory logic. Let E be a set of closed equations B

of combinatory logic. For combinatory terms A and ,

A B Ej A B

ECL if and only if CA .

2.2.2 The derived lambda abstractor S

The significance of the two combinators K and of combinatory logic lies in the fact that they can be used

SKK Ix x x

to simulate lambda abstraction. Define I . Notice that CL , for all . For a combinatory term

A C x V xA C C

and a variable , define the term C inductively:

xx I

xB KB x B

if FV

xB C S xB xC

otherwise

xAx A A xA A nfxg

Notice that CL can be shown by induction for any term . Also, FV FV .

We call the derived lambda abstractor of combinatory logic. It is important to remark here that, in general,

the operator is well-defined only on terms, and not on equivalence classes of terms. For this reason, the

Ax A A operator does not, in general, yield an operator , for a combinatory algebra . We will see

in Section 2.3.2 that we do get such an operator when A is a lambda algebra.

B C x x

n

Proposition 2.4. Combinatory completeness. For every term C with variables in , there

A B Ax x n

exists a closed term such that CL .

B x x A n

Proof. Let .

Ax x n

As a consequence, in the variety of combinatory algebras, all elements of can be written in

Ax x A A A n the form , where . However, such is not necessarily unique.

2.2.3 The local interpretation of lambda terms

C C

Using the derived lambda abstractor of combinatory logic, we can define translations cl C and

C C

C from lambda terms to combinatory terms and vice versa:

x x

x

xcl

c c

c

ccl

AB A B

MN M N

cl cl cl

K xy x

xM xM

cl cl

S xy z xz yz

Notice: Again, these translations are defined on terms, rather than equivalence classes of terms. For example,

z xxz SKII z z I

cl and cl are not equivalent in combinatory logic. The following hold:

M M M A B A B

Lemma 2.5. For any lambda term , we have cl . For combinatory terms ,if CL

A B M N M N M N A

then . For lambda terms ,if cl CL cl, then . For a combinatory term ,

xA xA

.

23 We can now interpret lambda terms in any combinatory algebra, by first translating them into combinatory

logic via cl:

I C A

Definition. Local interpretation of lambda terms. Let A be a combinatory algebra and an

M N VA

interpretation of constants. For lambda terms C and a valuation , define

I I

M M

cl

I j M N i I j M N

cl cl

I fM N j M N I j M N g

Th C

This interpretation is not sound for the lambda calculus, since there are derivable equations, such as for

xxz z z I instance z , that do not hold in all combinatory algebras. In particular, Th need not be a lambda theory! This leads us to consider the class of lambda algebras, which are precisely those combinatory algebras that satisfy all the equations of the lambda calculus.

2.2.4 Lambda algebras

A C

Let be a combinatory algebra. Then A is the set of combinatory terms with one constant symbol for each

A I A A

element of . Let be the canonical interpretation of each constant symbol as itself, i.e. the

A B C A j A B I j A B

identity function. For A , we write instead of .

A A B C

Definition. A combinatory algebra is called a lambda algebra if for all combinatory terms A ,

A B A j A B

A homomorphism of lambda algebras is a homomorphism of combinatory algebras.

T T T

Example. For any lambda theory , the open term algebra C and the closed term algebra are

C

T j A B T A B

lambda algebras. In the open terms algebra, C iff . Proposition 2.6 (Curry). Lambda algebras form an algebraic variety. In fact, the class of lambda algebras can be axiomatized over the class of combinatory algebras by the following five closed equations, known as

the Curry axioms:

ssksskkk k sk k

1. k

sskssk skssk skksk k sk k

2. s

kkssksskksksk kk

3. s

ksskk skkssksskksk k k sk k

4. s

k sksskssks ssksskkskssk skssks 5. s

Proof. See [5]. We will give a different axiomatization of lambda algebras in Remark 2.20.

We denote the variety of lambda algebras by LA. We write LA for provability from the axioms and rules of

B A B combinatory logic plus the five Curry axioms. We also write A LA instead of LA . The following

complements Lemma 2.5:

A A A M N M N

Lemma 2.7. For any combinatory term , we have cl LA . For lambda terms ,if , then

M N A B A B A B

cl LA cl. For combinatory terms ,if , then LA .

E j A B A

If E is a set of equations, we write LA if for all lambda algebras and all interpretations

C A I j E I j A B

I ,if then . The following is a soundness and completeness theorem for the

N pure lambda calculus, i.e. for equations M that are provable in the pure theory . In Section 2.3.3, we prove a more general theorem for arbitrary theories.

24

M N

Theorem 2.8. Soundness and completeness for the pure lambda calculus. For lambda terms C ,

M N j M N

if and only if LA .

Proof. Soundness follows directly from the definition of lambda algebras. For completeness, notice that the

M N M N open term algebra of the lambda beta calculus is a lambda algebra in which iff .

Remark 2.9. Failure of ( ) for the local interpretation. The reason that we state the soundness and com-

pleteness only for the pure lambda calculus at this point is that in general, the local interpretation in a lambda

I j A B I j xA xB

algebra does not satisfy the rule ( ), i.e. it is not in general true that implies .

A counterexample is the closed term algebra M of the lambda- -calculus. Plotkin [46] shows that there

M N Z MZ NZ Mx Nx x

exist closed terms such that for all closed terms , ,but for a variable .

j Mx Nx M j xM x xN x Hence M ,but . The absolute interpretation, to be defined in Section 2.3.2, takes care of this problem.

2.3 Lambda algebras and indeterminates

x

2.3.1 A characterization of A for lambda algebras

Ax

Recall that for a combinatory algebra A, we denote by the algebra obtained by freely adjoining an

A A Ax

indeterminate x to in the variety of combinatory algebras. If is a lambda algebra then so is . More

f A B B generally, if A is a lambda algebra and is a homomorphism of combinatory algebras, then is a

lambda algebra. This is because lambda algebras are definable by closed equations (Proposition 2.6).

Ax If A is a lambda algebra, then has an interesting explicit description. The following construction

is similar to constructions given by Krivine [32] and, in the case of Curry algebras, by Freyd [19]. Let

A ks B B KS

A , and define , where

fa A j a ag ski i sk k

B where ,

a b sab

K kk

S ks

A a b B Note: ab denotes application in , and denotes application in .

Proposition 2.10. 1. B is a well-defined combinatory algebra.

A B aka

2. The map with is a well-defined homomorphism.

A C x C g B C

3. For every homomorphism f and every , there is a unique homomorphism

f g g ix B Ax

such that and . Consequently, .

ab ab xy xy Notice that CL , and . The proof of Proposition 2.10 relies on the following seven properties of lambda algebras. We will see later that lambda algebras are already characterized by these properties (see Remark 2.20).

Lemma 2.11. The following hold in any lambda algebra:

a sa sa

b sab sab

c ka ka

d sskkab a

e sssksabc ssacsbc

f k ab skakb

g skai a

25

sa sa

Proof. One easily checks that , and similarly for the other equations.

Proof of Proposition 2.10:

a c K S a b i B a b B

1.: It follows by Lemma 2.11 Ð that all of , , , and are elements of , for any .In

a b c B

particular, the operations on B are well-defined. Moreover, for all ,

d

2.11

K a b sskkab a a and

e

2.11

S a b c sssksabc ssacsbca c b c

f

2.: Using Lemma 2.11 ,

abk abskakba b

af a x

3.: Define g , and check that this has the desired properties. For uniqueness, take any homo-

B C f h hix a B

morphism h such that and . Then for all ,

g

2.11

haha hskaihka ihka hiha hif a x g a

a b A ax bx Ax

Corollary 2.12. Let A be a lambda algebra, and . Then holds in if and only if

a b A

holds in .

a b A ax bx Ax

Proof. : Suppose and in . By Proposition 2.10, items 1. and 2., there is a unique

Ax B x i

map h extending and sending to . Then

g g

2.11 2.11

a skai ka i haxhbxkb i skbi b

a b A a b Ax ax ax bx bx Ax : in in in .

2.3.2 The absolute interpretation

M C x x x A

n

Let C be a lambda term whose free variables are among . Let be a combinatory

I

C A M

algebra, and let I be an interpretation of constants. The local interpretation , defined in

V A

Section 2.2.1, depends on a valuation of variables . Since, in fact, it depends only on the values

I n

x x M n A A n

of at , the local interpretation can be viewed as a function , sending an -tuple

x

n I

a A M M N A M N

to . In these terms, an equation holds locally in if and define the same

xa

n

A

function A .

Ax We will now consider a different interpretation of terms, interpreting M as an element in , i.e. as a

polynomial. We call this the absolute interpretation of M . The absolute interpretation distinguishes more terms than the local one, since, in general, two different polynomials may define the same function. For

closed terms, however, the absolute and the local interpretations coincide.

I C A

Definition. Absolute interpretation. Let A be a combinatory algebra, and let be an interpre-

A A C x x x

n tation of constants in . For each combinatory term C whose variables are among ,

abs

A Ax

we define its absolute interpretation as an element of by the following inductive clauses. Notice

x

that although the absolute interpretation depends on I , we omit the extra superscript.

abs abs abs abs abs abs abs

x c I c K k S s AB A B x

i i

x x x x x x x

abs

A B I j A B We say that the interpretation I absolutely satisfies the equation , in symbols ,if

abs abs

B A FV A B x Ax Ay

, where . Notice that, since the canonical homomorphism is

x x

x y x

one-to-one for , this notion is independent of the choice of variables . The absolute interpretation of

M

lambda terms C is defined via the translation cl:

abs abs

M M

x x cl

abs abs

M N i I j M N j I cl cl

26

abs

Remark. In the language of universal algebra, is just the unique map making the following diagram

x

commute. Hence the local and the absolute interpretation can be defined in any algebraic variety.

C x

C

abs

fxg

C

I

x

I

Ax

A

The terminology “an equation holds absolutely” is justified by the following lemma:

A B C x A

Lemma 2.13. Let C be combinatory terms with variables in . Let be a combinatory algebra

C A and I an interpretation of constants. The following are equivalent:

abs

j A B

1. I ,

I j A B A Ax

2. , where is the canonical map,

I j A B f A B

3. f for all homomorphisms .

f A B VB g Ax B f

Proof. 1.3.: Consider and . Let be the unique map extending such

I f I f I f I

f abs abs

g x x i A g A B g B A B i

that i for all . Then and , hence , which

x x

I I

I j A B I j A B V Ax A B

proves f .3. 2.: Trivial. 2. 1.: iff for all , .

abs abs

x x A B i

Take i to get .

x x

xA xA

Lemma 2.14. In any lambda algebra, .

b c Proof. By definition of and Lemma 2.11 and . The next lemma, which is crucial for the soundness of the interpretation of the lambda calculus, holds for

absolute, but not for local interpretations.

A I C

Lemma 2.15. The rule ( ) is sound for the absolute interpretation. Let be a lambda algebra,

A A B C

an interpretation and C combinatory terms. Then

abs abs

I j A B I j xA xB

A B x y y n

Proof. Assume the variables of and are contained in .

Ax y j A B Ax y j xAx A B xB x

: Suppose . Then , hence by Corol-

y j xA xB

lary 2.12, A . The claim follows by Lemma 2.14.

Ay j xA xB Ax y j A xAx xB x B

: Suppose . Then .

x x Ax A

It follows from this lemma that the derived lambda abstractor is a well-defined operator

Ax B KS

if A is a lambda algebra. When is explicitly constructed as like in Section 2.3.1, then

x B A a turns out to be the map that sends every element to itself. Using this operator, the absolute interpretation of a lambda term can be defined directly, i.e. without relying on the translation cl into combinatory logic:

abs abs abs abs abs abs abs

c x x MN M N xM xM c

i i

x x x x x x xx

x Ax A

Proposition 2.16. In the category of lambda algebras, the derived lambda abstractor is

A B

natural in A, i.e. for all ,

x

Ax Bx

x x

A B

x ax a A xaxa

Proof. Any element of A can be written (not uniquely) as , where . Then

a xax xxax .

27 2.3.3 Soundness and completeness for lambda algebras

Proposition 2.17. Soundness. The set of equations that hold absolutely in a lambda algebra A is closed

A under the axioms and rules of the lambda calculus. As a consequence, Th is a lambda theory for any

lambda algebra A.

A Proof. Consider each axiom and rule of the lambda calculus. () and ( ) are satisfied because is a lambda

algebra. The rules (refl), (symm), (trans)or(cong) are trivially satisfied. Finally, the rule ( ) is satisfied by

Lemma 2.15. For the second claim, notice that a closed equation holds absolutely iff it holds locally.

Theorem 2.18. Soundness and Completeness for lambda algebras. Let E be a set of closed equations of

the lambda calculus. Then for lambda terms M N ,

E M N Ej M N

if and only if LA .

T

Proof. Soundness follows by Proposition 2.17. For completeness, observe that the open term algebra

T M N T M N

associated with the theory is a lambda algebra satisfying iff . E

Corollary 2.19. For a set E of closed equations of the lambda calculus, let cl be its translation into combi- N

natory logic. Then for lambda terms M and ,

E M N E M N

if and only if cl LA cl cl.

Remark 2.20. It is worth noting that Corollary 2.12, Lemma 2.15, and Proposition 2.17 were all proved

a g

using only the seven properties of Lemma 2.11. Hence, if a combinatory algebra A satisfies 2.11 Ð ,

A A then Th is a lambda theory, which implies that is a lambda algebra. Thus, the class of lambda algebras is axiomatized over the class of combinatory algebras by the properties in Lemma 2.11. Of course, these

axioms can be closed by using the derived lambda abstractor. However, after spelling everything out in terms k of s and , the axioms given in Proposition 2.6 are considerably shorter.

2.4 Lambda theories and lambda algebras form equivalent categories

In this section, we define the category of lambda theories, and we show that it is equivalent to the category of

lambda algebras.

C Ti C

Definition. The category LT of lambda theories is defined as follows: An object is a pair h , where

hC Ti T

is a set of constants and T a lambda theory in the language . The pair , like itself, is called

C

C C C

a lambda theory.Atranslation from to is a function . Any such extends uniquely

C

M c c M c c c c

n n n

to a function , defined by , where are the

C C

hC Ti hC T i C C

constants that appear in M . A morphism from to is named by a translation from to

T M N T M N M N

such that implies for all . and name the same morphism

C

T M M M

if for all . Composition is defined by . C

Theorem 2.21. The category LT of lambda theories is equivalent to the category LA of lambda algebras.

G F hC Ti

Proof. We define a pair of functors F LT LA and LA LT. sends a lambda theory to its

T F hC Ti hC T i

closed term algebra , which is always a lambda algebra. sends a morphism

C

f T T G A

to the homomorphism induced by . sends a lambda algebra to

C C C C

A Ai G f A B

h Th , which is a lambda theory by Proposition 2.17. sends a homomorphism to the

A a fa

translation with .

B

id F G A

Next, we describe a natural isomorphism LA . For every lambda algebra , define A

A F GA A aa A

Th by A . This is clearly a homomorphism, and it is natural in . To see

A

M a A A M a

that this is an isomorphism, notice that for every there is a unique with Th ,

A

M namely, a .

28

G F id F

In order to show the existence of a natural isomorphism LT , it now suffices to show that is full

F f T

and faithful. F is one-to-one on hom-sets by definition of morphisms in LT. is also full: if

C

T f M c c M fc fc

n n

is any homomorphism, then maps a closed lambda term to ,

C

c c M M n

where are the constants that appear in . This is because is equivalent to an applicative term

c c k s f f F n

made up from and the combinators and , which are preserved by . It follows that ,

C c f c c C

where is defined by choosing a representative of , for every . C

2.5 Lambda models

The notion of lambda model arises, as in [5], if one attempts to prove Proposition 2.17 with respect to the

equations that hold locally. To do this, one needs the “local” equivalent of Lemma 2.15:

A j A B A j xA xB

This property, which is called weak extensionality, does not hold in general. Hence one defines a lambda model to be a weakly extensional lambda algebra. From our point of view, lambda models can be characterized as those lambda algebras which are intrinsi- cally local: in a lambda model, an equation holds absolutely if and only if it holds locally. Or in other words: in a lambda model, every polynomial is determined by its behavior as a function. In the language of category theory, such a property is called well-pointedness, and indeed lambda models correspond to well-pointed lambda algebras in a sense that will be made precise in Proposition 2.27.

Proposition 2.22. The following are equivalent for a lambda algebra A:

1. A is weakly extensional.

a b A

2. A satisfies the following Meyer-Scott axiom: for all ,

x Aax bx

SKI

(MS) where

a b

3. every equation that holds locally in A already holds absolutely.

A A j A B FV A B x

Proof. 1. 3.: Let be weakly extensional and . Assume . By weak

abs

j xA xB A j xA xB extensionality, A . This is a closed equation, hence , and finally

abs

j A B A by Lemma 2.15.

abs

x A ax bx A j ax bx ax bx

3. 2.: We show (MS): Suppose for all , . Then by 3., i.e.

x a b

A . Hence by Corollary 2.12.

A j A B A j xAx A B

2. 1.: To show weak extensionality, suppose . Then

xB x j xA xB A j xA xB , hence by 2., A , hence by Lemma 2.14, . Lambda models are less natural than lambda algebras, because they do not form an algebraic variety. Histori- cally, lambda models were a vehicle for proving soundness and completeness theorems such as Theorem 2.18, see e.g. [5, Thm. 5.2.18]. We conclude this section by remarking that every lambda algebra can be embedded

in a weakly extensional one:

X AX

Proposition 2.23. If A is a lambda algebra and an infinite set, then is a lambda model.

AX ax bx x AX

Proof. We show the Meyer-Scott axiom: assume a b and for all . Then there is

X a b AY x X n Y ax bx AY x a b AY some finite Y with . Let , then in , hence in by

Corollary 2.12.

29 2.6 Models of the lambda--calculus

2.6.1 Curry algebras

I

A Curry algebra [33] is a lambda algebra with . Note that Curry algebras form an algebraic variety.

A

Proposition 2.24. A lambda algebra A is a Curry algebra if and only if Th is a lambda- -theory.

x M xM x xy xy M M xM x

Proof. If FV , then . Hence in any Curry algebra,

M M A A j xy xy xx I

. Conversely, if Th is a lambda- -theory, then . Hence Curry algebras are to the lambda--calculus what lambda algebras are to the lambda- -calculus.

2.6.2 Extensional models

A

An applicative structure is extensional if for all a b ,

x Aax bx

a b

Extensional combinatory algebras are Curry algebras, and hence models of the -calculus. Although extensionality is an intuitive property, extensional models do not form an algebraic variety: e.g. the closed

term algebra of the lambda--calculus is extensional, but the subalgebra of closed terms is not (see [5, Thm. 20.1.2] and [46]). In fact, a Curry algebra is extensional if and only if it is a lambda model, since

the Meyer-Scott axiom from Proposition 2.22 is equivalent to extensionality in the presence of the equation

I .

2.7 Lambda algebras and categorical models 2.7.1 Reflexive ccc models

In this section, we relate the combinatory models of the lambda calculus to the models that arise from a C

reflexive object in a cartesian-closed category. An object D in a cartesian-closed category is called reflexive p

if there exists morphisms e and such that

D

D

id

p

D

D

D

e

hD e pi C p e id

The triple is called a reflexive -model or a categorical model of -conversion. If also D ,

we speak of a categorical model of -conversion.

M M M fx x g

x n

One defines an interpretation x of each lambda term with FV as a

 n

n

D D g e

morphism . Assume that bound variables are renamed as appropriate. Recall that and are our

notations for the curry and uncurry operations, respectively.

i

n

x D i D

x x

i (the th projection)

 n

hM N i

x x x x

e

n n

 

n

D D D D MN

x x

 n

M

x x

p



n

n D

x M D D D

n x x

 n

Proposition 2.25. The following are properties of categorical models of -conversion:

30

1. Permutation. The interpretation is independent of the ordering of the free variables, or of the addi-

f ng f mg

tion of dummy variables, in the following sense: If is injective and

M fx x g

n

FV , then

M

x x

m



m

D D

h i M

 n x x

n



n

D

M fx x g FV N N fy y g M Nx

n n m

2. Substitution. Let FV and , and let

N N x x M

n n

denote the simultaneous substitution of for in . Then

M Nx

y

m

D D

M

x x

n



hN N i

 y n y

n

D

M N M N M N

x x

3. Soundness. If , then . In a categorical model of -conversion, if ,

M N

x x

then .

M M N M N

x x

Proof. 1. and 2. are straightforward by induction on the term . For 3., define iff ;

x M N x by 1., this is independent of the sequence of variables , as long as FV . Clearly, satisfies the

properties (refl), (symm), (trans) from Table 2.1. Moreover, it satisfies (cong) and ( ) by 2.; to see that it also

e p id e p id D

D

satisfies ( ), first note that D . Hence

D D

hxM N i

x x

e

pid

D

hM N i

xx x

n

D

D D

D D

hM id i

xx D

n

hid M N i

xx x

D

n

D D

xM N x

By definition, the composition along the top is , while by the Substitution Property 2., the

M Nx xM N M Nx

x

composition along the bottom is . This shows . Hence , and we are done with the first claim. The case for -conversion follows by a similar diagram chase.

2.7.2 Reflexive ccc models and lambda algebras

D e pi hA ksi

From a categorical model h , one can define a lambda algebra :

D

A (the hom-set)

habi

e

a b D D D

xy x

k D

xy z xz yz

D s

A ksi Lemma 2.26. h is a well-defined lambda algebra.

31

Proof. It is easy to show by induction on terms that for any combinatory term A,

A

hx x i

x x

 n

n



n

A D D

A B A B A B A j A B

x x Hence, . Remark. Every lambda algebra arises from a reflexive model. The construction of a cartesian-closed category from a lambda algebra is due to Scott [54], and it is also described in [31].

The following proposition relates various concepts of lambda algebras to corresponding concepts of the

f g D E

categorical interpretation. An object D in a category is well-pointed if for all ,

f

x

x f g

D E

g

f g D D We say that D is locally well-pointed if the same holds for all .

Proposition 2.27. D

1. A is a lambda model iff is locally well-pointed.

A p e id

2. is a Curry algebra iff D .

A D p e id

3. is extensional iff is locally well-pointed and D .

D

D D D Ax

4. .

n

Ax x D D

n

5. .

n

j M N M N D D 6. A iff .

abs n

j M N M N D D

7. A iff .

A I xxp id xy xy p p e a A

Proof. In , one first computes D , , and for all ,

a p e a

.

A f g D D x D f x g x

1. : Suppose is a lambda model and suppose such that for all , .

f p f f x f x g x g x g p g A x A

Let and . Then for all , hence

f g p e p f p e p g f g

. D

: Suppose is locally well-pointed. We show the Meyer-Scott axiom (see Proposition 2.22). Suppose

A x A ax bx x D

a b such that for all , . This implies for all ,

D D

aid

e D

x

D

D

e

bid

D

D D

a e b

hence, by local well-pointedness, the square commutes. Currying the square, we get e , hence

a b

. A

2. : Suppose is a Curry algebra. Then

p e e p p e e e I e p id id

D D

p e id

hence D .

p e id p p e p id I D : Suppose D , then . 3. From 1. and 2.

32

4. and 5. Consider the following two retracts:

D

Ax

and D

id

id

p

x

D

D

Ax

D

A

e

x

x a A a a

As we have seen in Section 2.3, the set A can be identified with those such that .On

D

D a D p e a a

the other hand, arrows can be identified with those such that , which is

D

a a Ax D

again just . This gives a one-to-one correspondence between the points of and

n

D D Ax x D D

n

. The correspondence is similar. Moreover, this correspondence induces

n

D D

a lambda algebra structure on , which turns out to be the natural “pointwise” one given by

habi

e

n

a b D D D D

xy x

n

k D D

xy z xz yz

n

s D D

A j M N M N VD M f N f D

x x

6. We have iff for all ,iff for

n

D all f .

7. Follows from 5. and Lemma 2.13.

33 34 Chapter 3

Unorderability

The formulation of the untyped lambda calculus, by Church and Curry in the 1930’s, has preceded its modern semantic theory by more than 30 years. It was not until the 1960’s that Dana Scott constructed the first truly “mathematical” models of the lambda calculus. Scott discovered that such models can be constructed by a combination of order-theoretic and topological methods. Specifically, he observed that there exist non-trivial

diagrams of the form

D

D

id

p

D

D

D e in certain cartesian-closed categories of complete partial orders and Scott-continuous functions. Recall that

an object D in this situation is called reflexive, and that it gives rise to a model of the lambda calculus in a canonical way as described in Chapter 2. The question now arises whether all models of the lambda calculus can be constructed in this way. This question must be modified, since a simple analysis reveals that every reflexive CPO-model is uncountable [48], while there are some countable models of the lambda calculus. Instead, one can ask the refined question: can every model of the lambda calculus be embedded in a reflexive CPO-model? Alternatively: does every lambda theory arise as the theory of a reflexive CPO-model? The answer is known to be negative: Honsell and Ronchi Della Rocca [27] have exhibited a lambda theory that does not arise from such a model. One may now further relax this question by asking: (i) Can every model of the lambda calculus be partially ordered? (ii) Can every model of the lambda calculus be embedded in one that admits a partial order? These two questions are the subject of this chapter. Let us call a lambda algebra unorderable if it does not admit a non-trivial partial order that is compatible with the algebra structure. Unorderable algebras are known to exist. Plotkin has recently constructed a finitely separable algebra, a property with implies unorderability. In Section 3.1, however, we show that one does not have to look very far to find unorderable algebras: the most natural term models of the lambda calculus, namely the standard open and closed term algebras, are unorderable. An application to reflexive CPO-models is discussed in Section 3.2. Question (ii) is more difficult to answer, as indicated by the fact that the answer is still unknown. Let us

call a lambda algebra absolutely unorderable if it cannot be embedded in an orderable one. In Section 3.3, T we give an algebraic characterization of absolutely unorderable T-algebras in any algebraic variety .We

show that a T-algebra is absolutely unorderable if and only if it has a family of so-called generalized Mal’cev operators. The question (ii) thereby reduces to the syntactic question whether it is consistent to add such Mal’cev operators to the lambda calculus. This is an open problem in general, but we discuss some special cases in Section 3.4. Finally, in Section 3.5, we relate various different notions of unorderability.

35 3.1 Lambda terms cannot be ordered

In this section, we investigate unorderable models of the lambda calculus. Let us first fix some terminology.

Preorders and partial orders were defined in Section 1.2.1. The unique minimal preorder on any set X is

called discrete, the unique maximal preorder is called indiscrete, and discrete or indiscrete preorders are

y y x called trivial. By convention, if we wish to refer to a preorder that satisfies x , we will not call

it trivial, but symmetric. Of course, a partial order is symmetric iff it is discrete iff it is trivial.

X

Applicative structures and combinatory algebras were defined in Section 2.2.1. Let be an applica- X tive structure. Recall that a preorder on is called compatible if the application operation is monotone in

both arguments with respect to , i.e. if

a b a b X a a b b a b a b and .

An applicative structure is called unorderable if it does not allow a non-trivial compatible partial order.

X ks Notice that if is a combinatory algebra, then a preorder is compatible if and only if applica-

tion is monotone in just the second argument. Monotonicity in the first argument then follows by considering

xx b a a a b f a f a a b

f , because implies .

KS

Recall that the open term algebra of the -calculus is the combinatory algebra C , where

C

C is the set of untyped lambda terms with constants from , is the application operation on terms, and

K S xy x xy z xz yz KS

and are the terms and , respectively. The closed term algebra is C

defined analogously, and similarly for the -calculus.

3.1.1 Plotkin’s unorderable algebra: Separability

In a recent paper [50], G. Plotkin has constructed a finitely separable lambda, a property which implies X

unorderability. Following an idea of Flagg and Myhill [43], Plotkin calls a subset A of a lambda algebra

A X X a A

separable if every function is realized by some element , meaning that for all ,

a a . A lambda algebra is said to be finitely separable if every finite subset is separable. Flagg and

Myhill noticed that finitely separable algebras do not allow non-trivial compatible preorders: This is because

X x y

if abare two distinct comparable elements in , then all pairs of elements are comparable via some

X a x b y with and .

3.1.2 The standard term algebras are unorderable

We will now show that the standard open and closed term algebras cannot be non-trivially partially ordered.

xxxxxx

Notice that these are not finitely separable. For instance, consider the terms and

xx I T

I . The term is unsolvable, while is in normal form. Let be another term in normal form. By

T RI T the Genericity Lemma (Barendregt [5], Proposition 14.3.24), whenever R , then . Hence,

and I cannot be separated.

How would one go about constructing a partial order on, say, the open term algebra of the -calculus?

y v

As a first approximation, one might take two distinct variables x and , and let be the preorder generated by

v y M v N N M

a single inequality x . For this preorder, one has iff is obtained from up to -equivalence

y M v N

by replacing some, but not necessarily all occurrences of the variable x by . In other words, iff

P x y M P xxy N Pxyy

there is a term (not itself containing or ) such that and . This preorder is

v x non-trivial, because y . But is it a partial order? The following lemma, to be proved in Section 4.4, shows

that this is not the case:

A Axxxy Axyyy

Lemma 3.1. There exists a closed term of the untyped lambda calculus with ,but

Axxxy Axxy y Axyyy x y

for variables .

v Axxy y v Axyyy Axxxy

Notice that in the preorder that we have just defined, Axxxy . But since

Axxy y v x Axxxy , the preorder is not antisymmetric, hence not a partial order. By the same reasoning,

and y cannot be related in any compatible partial order on open terms. To show this section’s main result, we

36

y u t

need to replace the variables x and by arbitrary terms and . This is achieved by the following lemma,

su st

which states that, if s is a fresh variable, then and behave essentially like indeterminates: any equation

st x y T

that holds for su and will hold for variables and . Let be one of the theories or .

u u T s n

Lemma 3.2. Let be terms that are distinct with respect to .If is a variable not free in

u u su su su M N

n n

, then behave like generic arguments. More precisely, for all terms with

s M N x x n

FV , and for variables ,

M su su su N su su su

n T n

implies

Mx x x Nx x x

n T n

fz z z g u u

m n

Proof. Let be a list of all the free variables of the terms . Choose fresh, distinct

c c d d i n u u

m n i i

constants and .For , let be the closed term obtained from by replac-

u u c z c z

i m m

ing free variables with the appropriate constants: i . Further, add to the lambda

C u d i n T i

calculus a new constant and equations i , for . Let denote the theory that is

f g

obtained in this way on C . Then

M su su su N su su su

n T n

M u u N u u

n T n

(by renaming)

Md d Nd d

n T n

T

The claim now follows from the fact that T is conservative over . This is a consequence of Plotkin’s

T A

separability result [50]: the closed term algebra can be embedded in a separable algebra. Let

C

A u d i n i

be such an embedding. Then choose such that i , for . There is a unique

T A

extension of , sending to . Clearly, the theory induced by is a conservative

C

extension of T satisfying the additional equations.

M Theorem 3.3. Let M be the open or the closed term algebra of the -or -calculus. Then does not

allow a non-trivial compatible partial order.

M u t M

Proof. Let be a compatible partial order on . Let , and assume, by way of contradiction,

t A s

that u . Let be as in Lemma 3.1, and let be a fresh variable. Then by compatibility,

sAsususust sAsusustst

sAsuststst

sAsususust

hence, by antisymmetry,

AsususustAsusustst

xy Axxxy N xy Axxy y Axxxy Axxy y

Applying Lemma 3.2 to M and , one gets for variables

y A x and , contradicting the choice of . Consequently, the order is trivial.

3.2 The Topological Completeness Problem C Recall that, for any cartesian-closed category C,areflexive -model is a model of the lambda calculus that

arises from a diagram

D

D

id

p

D

D

D e

37 in the category C (see Section 2.7). These models have been particularly well studied in the category CPO

of cpo’s and Scott-continuous functions. Reflexive CPO-models are sometimes referred to as continuously

D D f D complete, because every Scott-continuous function f is definable by an element . Honsell and Ronchi Della Rocca [27] also use the term topological model. The following is a long standing open

problem ([27]): Open Problem. (Topological Completeness) Is there a reflexive CPO-model whose theory is or ?

Two related questions have been answered: Honsell and Ronchi Della Rocca [27] have shown that there is a C

lambda theory which is not induced by any reflexive CPO-model. The reflexive CPO-models are thus

incomplete for arbitrary lambda theories. On the other hand, Di Gianantonio et al. [16] have shown that

can arise as the theory of a reflexive CPO -model. If and denote, respectively, the first infinite ordinal

and the first uncountable ordinal, then CPO is the category whose objects are - and -complete partial

orders, and whose morphisms preserve limits of -chains (but not necessarily of -chains). However, the construction given in [16] makes decisive use of non-Scott-continuous functions.

We will now explore some consequences of Theorem 3.3 for topological completeness. First, one notices that in all models whose theory is or , the denotations of closed lambda terms necessarily form a

discrete subset: Corollary 3.4. In any partially ordered lambda algebra whose theory is or , the denotations of closed terms are pairwise incomparable. Proof. The set of closed term denotations is a sub-lambda algebra which is isomorphic to the closed term

algebra; hence the partial order is discrete on it by Theorem 3.3.

D z D

Recall that two elements x y of a partially ordered set are called compatible if there exists with

x z y z

and . We can now show that any complete reflexive CPO -model, if such a model exists, must

satisfy one of two peculiar properties:

D

Theorem 3.5. Suppose is a reflexive CPO -model whose theory is or . Then either:

1. The denotations of closed terms are pairwise incompatible, or

N x y D

2. There exist closed lambda terms M and such that, for all ,

x y y x Mxy Nxy

or t

Proof. Suppose 1. does not hold, i.e. there are two distinct closed terms u and whose denotations have an

D A M xy r sAsrxsrxsrxs ry

upper bound v . Let be as in Lemma 3.1, and let and

xy sAsrxsrxsry sry

N .

x y y x Mxy Nxy

: Suppose or . Then by the same reasoning as in the proof of Theorem 3.3.

Mxy Nxy x y D r D D : Suppose, by way of contradiction, that for incomparable . Define

by

z x z y

if and

z x z y

u if and

r z

t z x z y

if and

z x z y

v if and

r D

Then r is continuous; suppose it is represented by . Then

D j sAsususustMxyr Nxyr sAsusustst

But the proof of Theorem 3.3 shows that the first and the last term are -different, contradicting the assumption that D was a complete model.

38 3.3 A characterization of absolutely unorderable algebras

In Section 3.1, we have shown that the combinatory algebra of open lambda terms cannot be non-trivially ordered. However, it can be embedded in an orderable algebra; this follows e.g. from the work of Di Gi- anantonio et al. [16]. Plotkin conjectures in [50] that there exists a combinatory algebra which is absolutely

unorderable, i.e. which cannot be embedded in an orderable combinatory algebra. In this section, we charac- T

terize, for any algebraic variety T, those -algebras which are absolutely unorderable.

T A

Let T be an algebraic variety. Recall that a preorder on a -algebra is compatible if whenever

a b i k fa a fb b k f

i k k k i for , then , for each -ary function symbol . Notice that

monotone preorders are closed under arbitrary intersections. If is monotone, then so is the dual preorder

A

. Every monotone preorder determines a congruence on , which is the intersection of and . Also

A

notice that naturally defines a partial order on . A

A T-algebra is said to be unorderable if it does not allow a non-trivial compatible partial order. Also,

A B T B A is said to be absolutely unorderable if for any embedding of -algebras, is unorderable.

3.3.1 Absolutely unorderable algebras and generalized Mal’cev operators

A Au t u t

Consider a T-algebra . Let be the smallest compatible preorder on such that .

A a b a b a b A

Lemma 3.6. is trivial on , i.e. for .

Au t Ax u t x

Proof. Let be the kernel of the canonical morphism which sends both and to . Then

Au t u t

is a congruence, hence in particular a compatible preorder on . Since also , by definition is

A

contained in it. But , hence , is trivial on .

t u

Lemma 3.7. A is absolutely unorderable if and only if .

A A Au t Au t

Proof. : Suppose is absolutely unorderable. Consider the natural map  .

Lemma 3.6 implies that, the composition is an embedding, hence must be trivial as a partial order on

Au t Au t u t t u

 . Equivalently, as a preorder on is symmetric. Since , it follows that .

A F A B T

: Suppose is not absolutely unorderable. Then there is an embedding of -algebras where

U T B U T

B has a non-trivial compatible partial order . Hence there are such that . Consider

G Au t B u U t T Gj F a b Au t

the unique map such that , and A . Define in iff

a Gb B Au t u t

G in . Then is a compatible preorder on . But , hence is contained in . But

u t u

t , hence .

Au t a b

Further, has the following explicit description: On , define if and only if there is a polynomial

Ax x x Ax x x At u ua At t ub

such that and .

Lemma 3.8. is the transitive closure of .

Proof. Notice that is reflexive. Let be the transitive closure. Clearly, , and hence , is contained

Au t u t

in . On the other hand, is a preorder on satisfying . To see that is compatible, let

f k a b i k A x x x

i i

be a -ary function symbol in . First assume i for . Then there are

Ax x x i k A t u u a A t t u b i

i i i i

, for , such that and for each . By considering

Ax x x f A x x x A x x x fa a fb b

k k k

, it follows that . Hence is

compatible, which readily implies compatibility for . Therefore, is contained in .

Putting this together with Lemma 3.7, we get the following characterization of absolutely unorderable alge-

u tq u t A Au t bras. Recall that an equation p holds absolutely in iff it holds in .

39 T

Theorem 3.9. Characterization of absolutely unorderable T-algebras. Let be an algebraic vari-

A n

ety. A T-algebra is absolutely unorderable if and only if, for some , there exist polynomials

x x x Ax x x i n A

Mi , for , such that the following equations hold absolutely in :

t u u t

M

t t u t u u

M M

t t u t u u M M (3.1) .

.

t t u u

M n

A t t Au t

n

Proof. By Lemmas 3.7 and 3.8, is absolutely unorderable if and only if there are

t t t u n

such that . The corollary follows by definition of .

t t u u t t u u In the case n , the equations (3.1) have the simple form M and M . These equations were first studied by A.I. Mal’cev [37] to characterize varieties of congruence-permutable algebras

(so-called Mal’cev varieties). A ternary operator M satisfying these equations is called a Mal’cev operator.

n Accordingly, we call M M satisfying (3.1) a family of (generalized) Mal’cev operators, and we call the equations (3.1) the (generalized) Mal’cev axioms. Hagemann and Mitschke [25] have shown that an

algebraic variety has n-permutable congruences if and only if it has operators satisfying the axioms (3.1). It

was proved by W. Taylor [63, 11] that algebras in a variety with n-permutable congruences are unorderable; however, the converse, to the best of my knowledge, is a new result. Also note that Theorem 3.9 characterizes individual algebras that are absolutely unorderable, rather than varieties of unorderable algebras.

3.3.2 An application to ordered algebras and dcpo-algebras

I O

Recall from Section 1.3.5 that an algebraic signature and a set of inequations define a variety of

I P O

ordered algebras. The free ordered -algebra over any poset was denoted by P . One may ask under

P O

which circumstances the canonical map P is order-reflecting. The following theorem shows that

I k

the answer depends only on the presence of Mal’cev operators in . Recall that a -ary operation in is

tx x k

simply a -term .

I P

Theorem 3.10. Let be a signature and a set of inequations. Let be a non-trivially ordered poset and

P O P I P

let P be the canonical map from into the free ordered -algebra over . The following are equivalent:

1. is not order-reflecting.

I

2. Every ordered -algebra is trivially ordered.

I n

3. There are ternary operations M M in such that entails

t t u u

M

t t u t u u

M M

t t u t u u M M (3.2) .

.

t t u u

M n

B I ab

Proof. 1. 2.: Suppose is a non-trivially ordered -algebra with elements . We show that

P x y g P B

is order-reflecting. Let x y with . Define by

z y

a if

g z

z y b if

40

g O

Then is monotone; therefore, by the universal property of P , there exists a unique homomorphism of

h O g h h g xhx hy

ordered algebras P such that . By monotonicity of ,weget

y a x y

g , hence .

I O

2. 3.: Suppose every ordered -algebra is trivially ordered. Then, in particular, V is trivially or-

s t I t s I

dered, and hence I ineq iff ineq . We can therefore regard as a set of equations. The claim

A O

follows by applying Theorem 3.9 to .

I I B a b B

3. 2.: Suppose has operators satisfying (3.2). Then for any -algebra ,if , then

b b a a b b a b b a a B

n

M M M , hence is trivially ordered.

P O

2. 1.: A map P from a non-trivially ordered set into a trivially ordered one cannot be order-

reflecting.

Remark. Notice that the proof of 3. 2. shows that the inequalities (3.2) already imply the corresponding equalities (3.1). The equivalent of Theorem 3.10 holds for dcpo-algebras as well. This is due to the following lemma, which

relates the existence of non-trivial dcpo-algebras to the existence of non-trivial ordered algebras:

I I

Lemma 3.11. Let be a signature and a set of inequations. There exists a non-trivially ordered -

I dcpo-algebra if and only if there exists a non-trivially ordered -algebra.

Proof. : Trivial, since every dcpo-algebra is an ordered algebra.

hA i I A I A

: Let be an ordered -algebra. We consider the completion of : A subset is

A A

an ideal if it is downward closed and directed. Let J Idl , the ideal completion of , be the set of all

I

ideals, ordered by inclusion. Abramsky and Jung [3] prove that J is a -dcpo-algebra. Moreover, the

J x x J A

map A is order preserving and reflecting, and hence is non-trivially ordered if is.

I D

Corollary 3.12. Let be a signature and a set of inequations. Let be a non-trivially ordered dcpo and

D D D I D

let D be the canonical map from into the free ordered -algebra over . The following are equivalent:

1. is not order-reflecting.

I

2. Every -dcpo-algebra is trivially ordered.

I n 3. There are ternary operations M M in such that entails (3.2).

Proof. The equivalence of 2. and 3. follows from Theorem 3.10 and Lemma 3.11. The implication 2. 1. g is trivial, and 1. 2. follows as in the proof of Theorem 3.10; notice that the function defined there is

continuous.

3.4 Absolutely unorderable combinatory algebras

If A is a combinatory algebra, then the statement of Theorem 3.9 takes a particularly simple form, due to

combinatory completeness: A combinatory algebra A is absolutely unorderable if and only if there are a

n A A n

number and elements M M such that the following hold absolutely in :

t tuu

M

ttu tuu

M M

ttu tuu M M (3.3) .

.

ttu u

Mn

41

tuu A tut

Note that if is a lambda algebra, one can replace these equations by the closed equations M etc. But does an absolutely unorderable combinatory algebra exist? Unfortunately, this is not known. Clearly,

an absolutely unorderable combinatory algebra exists if and only if the equations (3.3) are consistent with the

n n axioms of combinatory algebras for some n. The answer is only known in the cases and .In

these cases, (3.3) is inconsistent with combinatory logic, as we will now show. Notice that if the axioms are

xy z z n m n

m consistent for some , then also for all , by letting M n M

Let Y be any fixpoint operator of combinatory logic, for instance the paradoxical fixpoint combinator

f xf xxxf xx xM Y xM

Y . Write for . The operator satisfies the fixpoint property:

xAxAx xA (fix)

The diagonal axiom is

y xAx y xAx x

The following lemma is due to G. Plotkin and A. Simpson: Lemma 3.13 (Plotkin, Simpson). Assuming the diagonal axiom, the Mal’cev axioms (3.3) are inconsistent

with combinatory logic for all n.

xz z x A z A z x x

Proof. Let be arbitrary. Let M . Then . Also,

x A z xz z

M

y z xy z by

M

z xxz by

M (fix)

z xz z by

M

z xxz

Mn

z z by

z z x

Hence x for all , which is an inconsistency.

Theorem 3.14 (Plotkin, Simpson). For n , the Mal’cev axioms are inconsistent with combinatory logic.

A y z xy z

Proof. Suppose M is a Mal’cev operator. Let x be arbitrary and let M . Then

Malcev

(fix) (fix) 

z xAz xAA x

A M M

z xAz z xxz z z

hence x M M .

Theorem 3.15 (Plotkin, Selinger). For n , the Mal’cev axioms are inconsistent with combinatory logic.

A B Proof. Suppose M and M are operators satisfying the Mal’cev axioms (3.3). Define and by mutual

recursion such that

xAB xAB A xf

M M

B y z f AB y AB z M M

Then

B f AB B AB B by

M M (fix)

f AAB AAB by

M M

A by

(fix)

xf xx xf xAA xAAA B y z f AAy AAz y z f y z

So M M M M , which is

the diagonal axiom. By Lemma 3.13, this leads to an inconsistency.

42 3.5 Relating different notions of unorderability 3.5.1 Local notions We defined a combinatory algebra to be unorderable if it does not allow a non-trivial compatible partial order. There are other notions of unorderability that are worth investigating. For instance, one can ask for the existence of non-symmetric preorders instead of partial orders. Or one can ask for the (pre)order to be

compatible with abstraction as well as with application: is called a lambda-(pre)order if it is compatible

and

x Aax bx

a b

We thus arrive at the following four unorderability notions for a combinatory algebra A:

1. unorderable if every compatible partial order on A is trivial.

2. un-preorderable if every compatible preorder on A is symmetric. A

3. un--orderable if every lambda-order on is trivial. A 4. un--preorderable if every lambda-preorder on is symmetric. Between these notions, only the obvious implications hold:

unorderable

un-preorderable un--orderable

un--preorderable

To see that no other implications hold, first observe that the open term algebra is unorderable, but -pre-

M N M N D

orderable: let iff for all valuations , in the standard -model. It follows from D

[29, 64] that this preorder is non-trivial; it is a lambda-preorder because the order on the standard -model is pointwise. The counterexample in the other direction is due to G. Plotkin, and it is given in the following theorem:

Theorem 3.16. (G. Plotkin) There is an extensional, partially ordered lambda algebra A that does not allow a non-trivial lambda-preorder. Proof. The idea of the construction is to work in a category where the order relation on function spaces is not pointwise. We use the category of meet cpo’s and stable functions CPO , which was defined in Section 1.2.4. Recall that the objects of this category are cpo’s with bounded binary meets which act continuously, and that

the morphisms are stable functions, i.e. continuous functions preserving the bounded meets. As we outlined

D in Section 1.2.5, the usual Scott -construction of models of the lambda- -calculus goes through in this

category.

D

n

D D D

n

Let be the cpo with two elements . Define to be the stable function space . Then

n

D B I T B T I

has three elements , where is the constantly function, is the constantly function, and D

is the identity. Notice that the stable order on is as shown:

T I

B

D D

43

e D D T B p D D f f

Define to send to and to , and define to send to . The pair

he p i e p

is is an embedding-projection pair in the category CPO , in particular, is stably less than

the identity. From this, one constructs the other embedding projection pairs and takes the inverse limit D as

D

D D D usual. Then , and as a lambda algebra, is extensional by Proposition 2.27. Clearly the order on

D is non-trivial and compatible.

For convenience, we identify all relevant function spaces with the corresponding subspaces of D . Let

p D D D D e

n n n n be the projection of onto , and the corresponding embedding.

Now suppose that v is a lambda-preorder. We will show it is trivial, i.e. it is either discrete or indiscrete.

I

First notice that, since we are in an extensional model, and hence

x Dax v bx

(3.4)

a v b

D

n

D f D D x D

n

Chasing the definition of the -model, one calculates that for and , the applica-

n

f x e f p x f v g D f x v g x

n n

tion is given by n . From this and (3.4), it follows that iff for

x D

all n . One distinguishes three cases:

I v T x y D f D D f I x f T y

Case 1: . For any pair of elements , define by and

f D B x v y v and f . This is stable and therefore realized by some . We get that and hence is

indiscrete.

v I

Case 2: T . Similar.

v T T v I

Case 3: Neither I nor . Suppose, by way of contradiction, that there are distinct elements

x y D x v y n x p x y p y

n n n

such that . Then for some the projections n and are distinct. Since

p p D x v y x y

n n n n

the projection n itself is realized by some , one gets . But then, since , there are

n

z z D D a x z z a y z z

n n n n n

n in such that and are distinct elements of

D a v a v v

. One then knows that , and hence it must be the case that either or . In the first case,

one has

I v T

I v T

I v T T v I hence, since v is a lambda-preorder, . Similarly, in the second case, one has , the required

contradiction.

3.5.2 Absolute notions There is a multitude of notions of absolute unorderability that one can consider. Fortunately, we will see that

all of them coincide. Recall that we defined a combinatory algebra A to be absolutely unorderable if for

B B every embedding A , the algebra is unorderable. First, one can adapt this with respect to preorders, lambda-orders etc. Second, one can replace the word “embedding” by “homomorphism”. Third, one can restrict attention to certain subcategories, e.g. lambda algebras or lambda models.

Instead of cataloging some 30 different notions and showing them all to be equivalent, we start with some A

simple observations. If P is some property of objects in a category, we say that an object absolutely

A B B P satisfies P if for all , satisfies .

First notice that, since lambda algebras are defined by closed equations, their full subcategory is right-

B

closed in the category of combinatory algebras: i.e.,ifA is a homomorphism of combinatory algebras,

B A and A is a lambda algebra, then so is . Hence, a lambda algebra satisfies some property absolutely as a lambda algebra iff it does so as a combinatory algebra. The corresponding property is true for Curry

algebras. P Next, there are some obvious implications: if A absolutely satisfies with respect to homomorphisms, then also with respect to embeddings. We also have the implications that were discussed in Section 3.5.1. It therefore suffices to show, for each of the categories of combinatory algebras, lambda algebras, and Curry algebras, that the weakest notion that we are considering implies the strongest one. This is done in the following proposition.

44

Proposition 3.17. For a combinatory algebra A, the following are equivalent:

B B

1. There is A for some non-symmetrically preordered combinatory algebra .

B B 2. There is A for some non-trivially partially ordered combinatory algebra .

For a lambda algebra A, the following are equivalent:

B B

3. There is A for some non-symmetrically preordered lambda algebra .

B B 4. There is A for some non-trivially lambda-ordered lambda model .

For a Curry algebra A, the following are equivalent:

B B

5. There is A for some non-symmetrically preordered Curry algebra .

B B

6. There is A for some non-trivially lambda-ordered extensional algebra .

A B B B B B

Proof. 1. 2.: Suppose and is non-symmetrically preordered. Let , then

B B B A

is non-trivially partially ordered and A . Now let , which is non-trivially ordered by the

A B

componentwise order where A is discrete. We have .

A B B A B

3. 4.: Suppose and is non-symmetrically preordered. First, construct as in 2.;

B B X X B X then consider A for a countable set . We know that is a lambda model by

Proposition 2.23. It has a non-trivial lambda order by Lemma 3.18 below.

5. 6.: Same as 3. 4.

B

Lemma 3.18. Suppose is a non-trivial partial order on a lambda algebra . Then extends naturally to

X X

a lambda-order on B , for countable .

Ax

Proof. First, consider the case of adjoining a single indeterminate A . Let be a partial order on

Ax a b xa xb a b A

A, and define on the partial order iff . Notice that if and were in , then

xa Ka xb Kb a b Ax Ka Kb A a b A

and , hence in iff in iff in , i.e. the order

x A BX

on A is an extension of the order on . Now consider , which can be regarded as a union of an

B Bx Bx x B

ascending chain of subsets . Starting with a partial order on , one can

X ax bx

extend it step by step to all of B . In the limit, we obtain a lambda-order, because if for all

x a b A Bx x n x x ax bx Ax

n n n n n

, then for some and one can take . But in iff

x ax x bx A a b

n n n n in , i.e. . Finally, notice that none of the local notions of unorderability that we have considered implies absolute unorderability: Plotkin’s finitely separable algebra [50], although it cannot be non-trivially preordered, can still be embedded in an orderable algebra (for example by Theorem 3.9).

45 46 Chapter 4

Finite Lambda Models

It has long been known that a model of the untyped lambda calculus, in the traditional sense, can never be

finite or even recursive [5]. For instance, no consistent lambda theory equates any two of the countably many

xy y xy xy xy xxy Church numerals 0 , 1 , 2 , etc.; hence, these terms must have distinct denotations in any non-trivial model. Consequently, model constructions of the lambda calculus typically involve passing to an infinite limit, yielding unwieldy models in which term denotations or equality of terms are not effectively computable. By contrast, we introduce a notion of finite models for the lambda calculus. These finite models are models of reduction, rather than of conversion. Therefore, as we shall see, they are not subject to the usual limitations on size and complexity. Informally, by a model of conversion, we mean a model with a soundness

property of the form

M N M N

where is e.g. -or -convertibility, and is the function that carries a lambda term to its interpretation in the model. On the other hand, a model of reduction has an underlying partial order and a soundness property

of the form

M N M N

where is e.g. -or -reduction. Models of reduction have been considered by different authors [23, 30, 49]. We will focus here on a formulation which was given by Plotkin [49] in the spirit of the familiar syntactical lambda models [5]. The key observation here is that models of reduction, unlike models of conversion, may be finite, and that they can be easily constructed. In special cases, models of reduction allow a limited form of reasoning about convertibility of terms. This is the case for instance if the underlying partial order is a tree. We begin by reviewing syntactical and categorical models of reduction in Section 4.1. In Section 4.2, we introduce a reasoning principle for models whose underlying order is a tree. We also give a method for efficiently constructing such models. In Section 4.3, this is further specialized to the case where the underlying order is flat. Examples are given in Section 4.4. Some reflections on completeness properties

follow in Section 4.5. In Section 4.6, we investigate the connection between models of reduction and the D

-construction.

4.1 Models of reduction

4.1.1 Syntactical models of reduction

P i P

Definition. (Plotkin [49]) An ordered applicative structure h is a poset , together with a monotone

V

P P P P P binary operation . Let be the set of all valuations, i.e. functions from variables to .A

47

hP i syntactical model of -reduction is an ordered applicative structure together with an interpretation

function

V

P P

with the following properties:

x x

1.

MN M N

2.

xM a M a P

xa

3. , for all

j j M M

M M

4. FV FV

aM N xM xN

xa xa

5.

P i

Moreover, we say h is a syntactical model of -reduction, if it also satisfies the property

xM x M x M

6. ,if FV .

hX i X A syntactical model of conversion is a syntactical model of -reduction , where is discretely ordered, i.e., a set. Notice that this notion coincides with the familiar syntactical lambda models as defined

e.g. in [5].

Remark. Properties 1.Ð3. do not form an inductive definition; rather they state properties of a function

which is given a priori. In particular, 3. does not uniquely determine the interpretation of a lambda abstraction

xM

. We have seen in Chapter 3 that many models of conversion are equipped with a partial order. This, however,

is entirely different from the partial order we consider on a model of reduction. Models of conversion have

b a

an approximation order, where a is often understood to mean that is “less defined” or “diverges more

a b a often” than b. On the other hand, models of reduction have a reduction order, where means reduces

to b. More precisely, one has the following soundness theorem:

Proposition 4.1 (Plotkin [49]). The following are properties of syntactical models of -reduction:

x x x M M

1. Monotonicity. If for all , then .

M Nx M

xN

2. Substitution. .

M N M N

3. Soundness for reduction. If , then . In a syntactical model of -reduction: If

M N M N , then .

Syntactical models of -reduction are easily constructed. One may, for example, start with any pointed poset

P P P P xM

and monotone function , and define, somewhat uningeniously, . Among the possible interpretation functions on a given ordered applicative structure, this choice is the minimal one. Much more interesting is the situation in which there exists a maximal such choice. We will explore such a situation in Section 4.2.2.

4.1.2 Categorical models of reduction

Let D be a cartesian-closed category of posets and monotone functions, with the pointwise order on hom-sets.

hP e pi P D

Definition. A categorical model of -reduction is given by an object , together with a pair

P P

P P p P P

of morphisms e and , such that

P

P

id

p

P

P

P

e

p e id hP e pi

If moreover P , then is a categorical model of -reduction.

48 Categorical models of reduction have been studied by various authors, e.g. by Girard [23] for the case of qualitative domains, or by Jacobs et al. [30], where they are called models of expansion. For a detailed

discussion of these and other references, see Plotkin [49].

P e pi

From a categorical model of reduction h , one can construct a syntactical model of reduction

P i a b eab

h by letting and by defining inductively:

x x

MN eM N

xM paM

xa

P e pi

Proposition 4.2. If h is a categorical model of -reduction, then the above construction yields a

hP i hP e pi

well-defined syntactical model of -reduction . Moreover, is a categorical model of -

P i

reduction, then h is a syntactical model of -reduction.

aM

xa

Proof. To see that the inductive definition is well-defined, and in particular that the function

P D

indeed defines an element in P , it is best to work directly in the category and to define an interpretation

n

M M M fx x g P P

x n

x of each lambda term with FV as a morphism , just as we did

 n

for categorical models of conversion:

i

n

P x P i

x x

i (the th projection)

 n

i N hM

x x x x

p

n n

 

n

MN P P P P

x x

 n

M

x x



n

e

P n

P P x M P

n x x

 n

It is easily seen that the two definitions coincide in the sense that

M

hx x i

x x

 n

n



n

P M P

The verification that this is a syntactical model of -, respectively, -reduction is now routine.

4.1.3 Models of -reduction: Order-extensionality We have seen in Chapter 2 that an extensional model of -conversion is always a model of -conversion.

The property that corresponds to extensionality for models of reduction is order-extensionality: An ordered

P i

applicative structure h is called order-extensional if

x P ax bx

a b

hP i Lemma 4.3. If a syntactical model of -reduction is order-extensional, then it is a model of -

reduction.

x M a P xM x a Mx M x

xa xa xa

Proof. Suppose FV . Then for all ,

M a xM x M

, hence .

4.2 Tree models 4.2.1 Recapturing convertibility

The soundness property for models of reduction does not in general yield useful information about convert-

N M

ibility, since interconvertible terms may have different denotations. However, if the reduction under

N M Q M Q N Q consideration is Church-Rosser, then implies that there is a term with and .

49

M N a b

Therefore, the denotations and must be compatible. Recall that and are compatible, in sym-

b c a c b c

bols a , if there exists with and . In a model of reduction, one has the following restricted

form of soundness for convertibility:

M N M N

(4.1)

The latter property is especially useful if the underlying poset P has many pairs of incompatible elements.

Therefore, we will pay special attention to the cases where P is a tree or a flat partial order.

b a b P a a b a b

Definition. A pointed poset P is called a tree if for all , implies or . Equivalently,

P x P

for each x , the downdeal is linearly ordered. A tree is said to be bounded if there is a number

N x n n P n such that each has at most elements. The smallest such is called the height of . A model of reduction is called a tree model if the underlying poset is a tree.

4.2.2 A method for constructing models

In general, there may be many different ways of defining an interpretation function that makes a given

P i

ordered applicative structure h into a syntactical model of reduction. Even if one restricts attention to

hP e pi eaba b

those cases where is defined inductively from a categorical model , with , there is

P

P P p

a choice involved in determining the morphism p . In general, the greater is chosen with respect

to the pointwise order, the greater the resulting interpretation will be, and the better one will be able to

make use of the soundness property for convertibility 4.1.

e p

The best possible situation arises if we can find a right adjoint p of , because if is such a right adjoint,

p id P e P Q

then it is maximal with the property e . It is well-known that if is a complete lattice, then

W

py fx P j ex

has a right adjoint if and only if e preserves suprema. In this case, one can define

y g . But following the remarks in Section 4.2.1, we are interested in posets P that have incompatible pairs of elements, and which can therefore not be complete lattices. In the case of bounded trees, the existence of a

right adjoint is characterized by a property which we call strong extensionality:

hP i

Definition. Let P be a bounded tree. We say that an ordered applicative structure is strongly exten-

P

sional if for all a b ,

x P ax bx

a b

P

P i P e P P

Proposition 4.4. Let h be an ordered applicative structure, where is a bounded tree. Let

aba b e hP i be the map defined by e . Then has a right adjoint in the category of posets if and only if

is strongly extensional.

P

bx e p P P a b P ax x P

Proof. : Suppose has a right adjoint . Let such that for all . Since is

bx ax bx x f P P f x maxax bx

a tree, one has ax or for every . Define a monotone map by .

ax ax f x x ea f a pf b

Since e for all , one has and hence , and similarly for . Hence

b hP i

a , and is strongly extensional.

P

hP i f P P fx P j ex

: Suppose is strongly extensional. For any , consider the subset f

eb bx b f g P a b P ea ax x a

. Notice that for any f , , hence for all , hence by strong

P a b a b P P

extensionality. Since is a tree, either or . Therefore f is linearly ordered. Since is bounded,

P pf p

the set f is finite, and hence it has a maximal element . Clearly, the function thus defined is monotone,

x pf x P ex f e a p

and iff f iff . Therefore .

Corollary 4.5. The last proposition yields a practical method for constructing a tree model of reduction:

P P P hP i

Begin with a tree P and a monotone binary operation , such that is strongly extensional.

Define inductively as follows:

x x

1.

50

MN M N

2.

xM b P b a M a P

xa

3. is the maximal such that for all .

P i Then h is a well-defined model of -reduction.

Proof. Proposition 4.4, together with Proposition 4.2, ensures that this is well-defined, in particular, that a maximal b exists in 3.

The following lemma is sometimes useful for reasoning about such a model:

n n

Lemma 4.6. If is defined as in Corollary 4.5, then for all , the denotation of an -fold lambda

x x M b P a a X

n n

abstraction is the maximal such that for all ,

b a a M

n

x a x a

  n n

Proof. By induction on n.

P i If h is order-extensional, then the construction in Corollary 4.5 yields a model of -reduction by Lemma 4.3. We end this section with a lemma that relates order-extensionality to strong extensionality for

tree models:

hP i Lemma 4.7. If P is a tree, and if is strongly extensional and extensional, then it is also order-

extensional.

ax bx ax bx a b P

Proof. Suppose for all x, , hence , hence by strong extensionality. Since is a tree,

b a b ax bx ax bx

either a or . In the first case, we are done; in the second case, , and hence , for all

a b x, which implies by extensionality.

4.3 Partial models

As the examples in Section 4.4 will show, it often suffices to consider tree models whose underlying poset P

P X X P P P

is flat, i.e. for a discrete set . If one also assumes that the application operation is

strict in each argument, then one can think of as the undefined element, and of and as partial functions.

Since it is sometimes convenient to think in terms of these partial operations, we restate the definition of a

B

model of reduction in this special case. The venturi-tube denotes directed equality: A means that if B

A is defined, then so is , and they are equal.

X i X X XX

Definition. A partial applicative structure h is a set with a partial binary operation .

X V X hX i Let Val be the set of partial valuations .Apartial syntactical lambda model ,orpartial

model for short, is given by a partial applicative structure together with a partial map

X X X Val

such that

x x

1.

MN M N

2.

xM a M a X

xa

3. , for all

j j M M

M M

4. FV FV

aM N xM xN

xa xa 5. Moreover, if

51

xM x M x M

6. ,if FV .

X i

then h is a partial -model.

B A B

Here, equality is understood to be Kleene equality, meaning A if and only if and are either both

undefined or both defined and equal. Notice that the directed equality on X is just the partial order on the

X

flat poset . Thus, the axioms 1Ð5 and 6 correspond exactly to the axioms for a syntactical model of -,

respectively, -reduction. In a partial model, the denotation of some terms may be undefined. The idea of using partiality in models for the lambda calculus is not new. In fact, Kleene’s “first model”, which consists of G¬odel numbers of partial

recursive functions and their application, is partial. The models we consider here are even “more” partial; we K do not even assume that the interpretations of basic combinators such as S and are defined. The following soundness properties ensure that the class of terms whose denotation is defined is closed under reduction, and that interconvertible terms have the same denotation if they are both defined.

Proposition 4.8. The following are properties of partial models:

M N M N

1. Soundness for reduction. If , then .

M N M N M

2. Soundness for convertibility. If , and if and are both defined, then

N

.

3. In a partial -model, the respective properties hold for and . Proof. Soundness for reduction follows from Proposition 4.1. Soundness for convertibility follows from the

Church-Rosser property. Partial applicative structures are particularly easy to manipulate in practice, since they are just given by

a set X and a “multiplication table” such as the one in Table 4.1. It is easy to read properties such as strong extensionality off the table: A partial applicative structure is strongly extensional if no two rows of the

multiplication table are compatible, and it is order-extensional if no row is subsumed by another. In particular,

X i if the table is everywhere defined, i.e. if h is a total applicative structure, then both strong extensionality and order-extensionality coincide with (ordinary) extensionality.

4.4 Examples

4.4.1 A class of finite models to distinguish the terms n

n n n

x x x x x x n xx

n n n

Let be a variable and define and for . Let n and .

xxxxxx n

None of these terms has a normal form, e.g. reduces only to itself. The terms are

D unsolvable; therefore, their interpretations coincide with in the -model [29, 64]. We will now give a

class of finite partial models that distinguishes these terms.

p X Z f pg X p

Fix an integer and let p . Addition and subtraction in are modulo ; let

p X X

p denote equality modulo . Define by

n m

if p

n m

p

m m

if p

X i

A “multiplication table” for this operation is shown in Table 4.1. Clearly, h is a strongly extensional

n

n n

applicative structure. Define as in Corollary 4.5 to get a partial model. For , we calculate p

n

m m m x X n

and p for . Hence, for all and ,

n

x n x

p

n

xx n

n p

n n n

n n n p p

n n m

n m p Hence, n is always defined for , and we have iff .

52

Table 4.1: Multiplication table for a partial model

p p

p

p

p ......

......

p p p

p p

4.4.2 A non-trivial 3-element model

In this section, we provide the proof of Lemma 3.1 from Chapter 3. At the heart of the proof is a 3-element Auutt

partial model which distinguishes two appropriately chosen unsolvable terms Auuut and .

A Auuut Auttt Auuut

Lemma. There is a closed term of the untyped lambda calculus with ,but

Auutt Auttt u t

for variables .

Proof. Define terms

h zyxzzyzzyzzyx

f hh

A uv w txf ufvfwftx y

Then for all x, :

fyx fyfyfyx t

hence for all u, :

xf uftx xf ufufuftx Auuut

xf uftx xf uftftftx Auttt

Auuut Auutt u t X fk g

To see that for variables and , we will construct a partial model. Let ,

and let be defined by the following “multiplication table”:

k

k

X i

Then h is a strongly extensional applicative structure. Define inductively as in Corollary 4.5. Al-

X i

though h is total, will be partial.

c b a zzyzzyzzyx ccbccbccba

z cy bxa

Consider the function . Table 4.2

c b ak c b a c b a X

shows the values of this function, and one observes that for all . Hence

hz y xz z y zzyzzyx k f hh

by Corollary 4.5, is defined and equal to , and consequently

ux t

kk .If and , then

fufufuftx

fufuftftx

fufufuftx fufuftftx Auuut Auutt By soundness, .

53

c b a k c b a

Table 4.2: Values for and

c b a c b a k c b a

k k

k or or

k

k

k

k

4.5 Completeness

hP i hP i

Given a syntactical model of -or -reduction , one can define its lift as follows:

b a b

a if

a b

else,

M x x M

if for all FV

M

else. It is easily checked that this is again a model of -, respectively, -reduction. As a trivial consequence, one

has the following completeness theorem for partial models:

M N M N

Proposition 4.9. Completeness: If , then there is a partial model and for which , are

M N M N

defined and .If , then the model can be chosen to be strongly extensional.

M N

Proof. Take a model of conversion such that for some , e.g. a term model. Then its lift is a

M N

partial model with .

Of course much more interesting questions can be asked, e.g. how close one can come to a finite completeness

M N

theorem for models of reduction? In other words: can every inequality be demonstrated in a finite model of reduction? The answer to this question must be no, since such a finite completeness theorem would yield a decision procedure for convertibility of lambda terms, which is known to be an undecidable problem. It is an open problem to identify subclasses of terms for which a finite completeness property holds, or to

describe the class of equations that hold in all finite models of reduction, tree models, partial models etc. D

4.6 Relating models of reduction to -models

P

hP e pi e p id p e id P P

Consider a finite categorical model of reduction , such that P and . Since is

p P

finite, it is a dcpo and e and form a Scott-continuous embedding-projection pair. Therefore, one can take ,

e p D

and as the basis for carrying out the -construction in the category CPO, as outlined in Section 1.2.6.

D

n

D P D D e e D D p p D D

n

Let and . Let and . From this, construct the

n

D D D D D

n n n n other embedding-projection pairs and take the bilimit as usual. Let and

54

be the limiting morphisms. For each n one has

p

e

n

n

D D

n n

D D

D D

n n

n n

n n

n n n

n and

D D

D D

D D

e p

n

hD e p i hD e p i

n n

Note that each n and is a categorical model of reduction. Let and be the

V D

respective interpretation functions. How are they related? For a valuation of variables , denote

n

VD M M

n n n

by n the valuation . One may expect that . However, this is in general

n

n

not the case. The following proposition relates and :

Proposition 4.10. For all lambda terms M ,

n

M M

n

B

B

n

n

n n n

id p p

n n D n n

B

Proof. First recall from Proposition 1.7 that B . Also note that

n n n n

M p

n . The proposition is proved by induction on . There are three cases:

n

x x x x x

n n n n n

B B B

B B Case 1: B

n n n

n

IH

n n

M MN e M N e N

n n

BB B

Case 2: B

n n

n n

n n n n

n

e M e M N N

n n n n

B B

B B

n n n

n n n n

n n n n

e M N e M N

n n n n n n

B B

B B

n n

n n n n

n

MN

n

B

B

n

n

IH

n

M p a xM p a D M

n

B

Case 3: B

n

x a xa

n n

n n

n

b p p a M D M

n n

B B

B B

n n n

x a xb

n n n

n

n

b D M p

n n n

B

B

n n

xb

n

n n

xM p b D M

n n n n

B B

B B

n n

xb

n

n

n

M M M n

In particular, it follows that n for every , and by applying to both sides, it also follows

n

n

M M D

that n . To see that equality does not in general hold, notice that , by construction, is

n

M N M N D

n n n

a model of conversion. Hence for all , one has . On the other hand,

M N M N

is finite and hence a proper model of reduction. Therefore, it is possible to find with and

n n

M N

.

n n

n n

M N n M M N

Corollary 4.11. If and are lambda terms such that, for some , , then

n n

N D P

. The converse holds if is bounded complete (this is the case, for instance, if is a tree).

n

M N c D M N c M M n

Proof. Suppose . Let such that . Then

n

n

c N D n

n , and similarly for . For the converse, assume is bounded complete. Assume that for all ,

n

n n n n n n

M N M N n c M D N

n n n n

. Then for all . Let n in . Then

n n n n n n

n

c M N M c c

n n n n n

B B B

B B

is an increasing sequence and B , and similarly , hence

n n n

n

M N

.

55 56 Chapter 5

Henkin Representations, Polymorphism, and Empty Types

The polymorphic lambda calculus was independently discovered by Girard [22] and Reynolds [51]. It has been extensively studied as a prototypical programming language because of its great expressive power and economy of syntax. The basic idea is to augment the simply-typed lambda calculus with type variables

and with explicit universal quantification over types. This allows the formulation of algorithms that

uniformly handle data of more than one type. Type instantiation and type abstraction is made explicit on

t s

terms: If t is a term of type , then is a term of type , for all types . Conversely, if is a term

s

of type , then is a term of type . Now consider for instance the type

Polybool

t A term t of this type yields a term of type , for every type . Moreover, following Strachey’s

concept of parametric polymorphism [62], one expects the behavior of t to vary uniformly with the choice

of . In the polymorphic lambda calculus, there are only two such uniform functions of type Polybool, i.e.

there are exactly two closed terms of type Polybool, corresponding to the first and second projections:

p x y x p x y y and

Several notions of models for the polymorphic lambda calculus have been proposed in the 1980’s. These models follow one of two basic designs: 1. Environment-style models, which have been considered by Bruce and Meyer [10], extend the familiar

Henkin models of the simply-typed lambda calculus. These models are non-strict, in the sense that

a function type is interpreted as a subset of the set of functions from to , and similarly a

Q

universal type is interpreted as a subset of an infinite product . 2. Categorical models, introduced by Seely [56], are based on general principles for the interpretation of quantifiers in categorical hyperdoctrines. Seely’s PL-categories are a canonical extension of the ccc interpretation of the simply-typed lambda calculus. These interpretations are strict, in the sense that both function types and universal types are interpreted directly by their categorical counterparts. These two classes of models do not readily mesh, because it is known that strict interpretations collide with the classical foundations: Reynolds showed that there are no set-theoretic strict models of the polymorphic lambda calculus [52]. The aim of this chapter is to reconcile the categorical and the set-theoretical approaches by giving a categorical treatment of non-strict models. This generalizes both Seely’s models and the models of Bruce

and Meyer. The central concept is that of a Henkin representation: a functor H between ccc’s is a Henkin

57

A

H B

representation if it preserves finite products and if for all objects A B , the canonical morphism

H A

B H is monic.

In Section 5.1, we prove three Henkin representation theorems characterizing those ccc’s which can

S

be Henkin-represented, respectively, in the category of non-empty sets S , the category of sets , and

P P a category S of presheaves over some poset . After reviewing the simply-typed lambda calculus in Section 5.2, we show in Section 5.3 that the three Henkin representation theorems correspond naturally to completeness theorems for three different classes of non-strict models: Friedman’s set-theoretic models with non-empty types [21], set-theoretic models with possibly empty types, as investigated by Meyer et al. [39], and Mitchell and Moggi’s Kripke lambda models [42], respectively. Sections 5.4 through 5.6 are devoted to Henkin representations of PL-categories and their relationship to completeness theorems for the polymorphic lambda calculus.

5.1 Henkin representations of cartesian-closed categories

5.1.1 Henkin representations

D H C D

Definition. Let C and be cartesian-closed categories. A functor is called a Henkin repre-

C

sentation if it preserves terminator and binary products, and if for all objects A B , the canonical arrow

A HA

H H B HB

AB is monic.

C D

Recall that a ccc-representation F is a functor that preserves all ccc structure, and in particular

A FA

id F B FB F F AB and AB . Thus, every ccc-representation is a Henkin representa- tion, but not vice versa. Henkin representations arise naturally as the forgetful functors of various concrete

ccc’s into S . Even though Henkin representations do not in general preserve exponentials, they are ‘compat- ible’ with ccc structure in an essential way: their kernels are ccc-congruences. This is why they correspond

to useful notions of ‘model’ for typed lambda calculi.

C

Definition 5.1. A ccc-congruence on a ccc is given by an equivalence relation AB on each hom-set

A B

, such that the following hold:

f f g g f f f f g g

AB AC ABC AB BC

g f g f hf gi hf g i f B f

AC AB C

AC

F C D f f Ff Ff f f A B

The kernel of a functor is defined by AB iff , for all . Clearly,

the kernel of a ccc-representation is a ccc-congruence. The same is true for Henkin representations:

C D

Lemma 5.2. The kernel of a Henkin representation H is a ccc-congruence.

H f f Hf

BC

Proof. 1. and 2. are obvious, since preserves binary products. For 3., suppose A , i.e.

Hf . One has

H

H

B

B

B

HB

H C HB

C HC

C B

H C

HC

f id

B

H f id

HB

H f

f

Hf

Hf

A B

HA HB

HA

Hf Hf H H f H f

and similarly for f . Since , and since is monic, one gets . H

Remark 5.3. Henkin representations do not form a category, since they do not in general compose. If and

H H H H

are Henkin representations, then the composition will be a Henkin representation if preserves H monics or if is a ccc-representation.

58

Henkin representations can also be described in terms of partial exponential diagrams. We say that a diagram

f

B C g A B C

D is a partial exponential diagram if for every morphism , there is at most one

A D

h such that

f

D B

C

hid

B

g

A B

We have dropped the condition for the existence of h from the definition of exponential diagrams in Sec- tion 1.1.6. In general, the word “partial” stipulates that one requires uniqueness, but not existence, while the word “weak” or the prefix “pre-” indicates the opposite.

A Henkin representation of a ccc C can now be characterized as a finite product preserving functor

H

AB

A

HB C D A B C H B HA H such that for all , the arrow is a partial exponential

diagram. The advantage of this definition is that it makes sense for a category D with finite products, even if it is not cartesian-closed. Our definition of Henkin representations for PL-categories in Section 5.4.2 will

make use of a similar notion of partial -diagrams.

5.1.2 Henkin representations and well-pointed ccc’s

f g A B p A

Definition. An object A is well-pointed if for every , there is a point such that

p g p D f . A category is well-pointed if all its objects are well-pointed.

Note that for a ccc D, the following are equivalent:

1. D is well-pointed.

2. The point functor is an embedding.

3. is a Henkin representation.

C D C D

Proposition 5.4. Every ccc representation F from a ccc into a well-pointed ccc gives rise to

F C S H C S a Henkin representation H . Conversely, every Henkin representation arises

in this way.

F C S

Proof. If D is well-pointed, then is a Henkin representation by Remark 5.3. For the

A

C S D jDj jCj DA B H B

converse, suppose H is a Henkin representation. Define by and .

B A

C B

Composition and identities are given by the respective H -images of the canonical morphisms

A A

id A C

C and in . Associativity and the identity laws follow from the commutativity of the H

following diagrams in C, and of their images under :

hid id i

id

C B A C A A A

A

D C B D C B A

B

id

hid id i

id

B A B A

A A

D B B B

D B

A

C D f A B H f H B

Define F as the identity on objects, and by sending to

A B D F F H

D . It is routine to check that is a well-pointed ccc, that is a ccc representation, and .

59

5.1.3 Freely adjoining arrows to a ccc

x

C C A C

If A is an object of a ccc , let be the ccc obtained from by freely adjoining an indeterminate

x x

A C A C C A

arrow x . The category , together with the canonical ccc-representation ,

C D

is uniquely determined by the following universal property: for every ccc-representation F and

x

F CA D FA D

every arrow f in , there is a unique ccc-representation such that

x

CA

C

F

F

D

x

f C CA

and Fx . The category has a concrete description as the Kleisli category of the comonad

B A B C C

T (see Lambek and Scott [34]). This means, the objects of are those of , and the hom-sets

B C CA B V B C A B B C

are given by C . The identity at in is in , and the composition

hf i

g

f C A B A C D C x A C id A A C

g in is in . in is in . The canonical functor

C C f B C f A B C sends to .

It is an interesting question to ask which properties are preserved or reflected by the canonical functor

x

C CA . We will pay particular attention to the question under what conditions is an embedding,

and under what conditions it is faithful (i.e., isomorphism reflecting).

A B f Definition. In any category, a morphism f is called a cover if, whenever factors through a monic

m,

f

A B

m

U

f A B f A B

then m is necessarily iso. We sometimes write for a cover. Notice that any morphism

f g id f

with a right inverse B is a cover, called a split cover. Also notice that any is iso iff it is a monic

B A B B cover. An object A is called well-supported if for each object , the second projection is a

cover.

A B

An object A is partially initial if every hom-set has at most one element.

C D F

Lemma 5.5. Suppose F has a right adjoint. Then preserves epics and partial initial objects. F

Moreover, if C has pullbacks, then preserves covers.

F a G e B C

Proof. Let be the adjunction. Suppose is epic and

g g

Fe e

GD

FB FC D B C

h h

h g h Fe

which implies g , hence . Hence is epic. Dually, right adjoints preserve monics. Now

A jFABj FA jA GB j

suppose is partially initial. Then , hence is partially initial. Now assume

m

g

f A B Ff FA U FB G

C has pullbacks, and suppose is a cover. Assume . Since is a right

GU GF B

adjoint, Gm is monic, and we can consider

A

f

m

B

B FB

g

u

u

u

id

GU GF B

FB

GU GF B

U

m

Gm Gm

60

m

where u is the unit of the adjunction. Notice that pullbacks always preserve monics, hence is monic, and

m Ff

it must be iso since f is a cover. The last diagram implies that is iso, and it follows that is a cover.

x

CA C C Lemma 5.6. Let C and the canonical functor. The following hold:

1. preserves epics, monic cones, partial initial objects, and well-pointed objects.

A C

2. is an embedding if and only if the unique morphism is epic in . A

3. is faithful if and only if it is an embedding and is well-supported.

B A B

Proof. 1.: Recall that in a ccc, the product functor T has a right adjoint; hence it preserves

B C C g f h f

epics and partial initial objects by Lemma 5.5. Now suppose f is epic in and in

x

C A

C . By the characterization of , this means

g

id f

A

D

A B A C

h

g h f B C A B

holds in C, and hence . Thus, is epic. Now, suppose is a partial initial object in . Then

C B C j jCA B C j B C

is also partially initial, hence j , hence is partially initial in . Moreover,

B C f g B C

T , and hence , preserves monic cones. Now, suppose is well-pointed in , and suppose

A

f g A B C f g B C C B

in C . Then , hence in , and since is well-pointed, there is

p B f p g p f id p g id p f p g p C A

with . This implies A , hence in .

x

A CA

2.: : Certainly is epic in (it splits). But embeddings reflect epics.

A C A B B B f g B C C

: Suppose is epic in . Then is epic for all . Consider in

g f g A B C f g

with f . Then , hence . F

3.: First notice that any monic-preserving embedding F reflects isos iff it reflects covers: Suppose reflects

f m Ff Fm Fm

isos and Ff is a cover. Suppose factors through a monic , then factors through , hence is

f F Ff Ff f

iso, hence m is iso, hence is a cover. Conversely, suppose reflects covers. If is iso, then , hence ,

x

C C A is a monic cover, hence an iso. Since preserves monics, it suffices to show that reflects

covers iff A is well-supported.

x

A B B C A C

: Suppose reflects covers. Clearly, is a split cover in , hence a cover in , making C

A well-supported in .

x

A C f C B Ff C A

: Suppose is well-supported in , and suppose is such that isacoverin .

x

m D C Ff Fm Fm C A

Suppose f factors through a monic . Then factors through , hence is iso in .

C C D CA C D C

This means, there is m such that in ,

A C

C

m



m

D

m C f

But is a cover, therefore an iso in . This shows is a cover.

x

g A B C f x g x C A

Lemma 5.7. If f in , then in .

f x f hid id i f C g x A

Proof. A in , and similarly for .

AjCj A A A

Proposition 5.8. Let C be a small ccc. If is a set of objects such that for all , then

F C D FA A A F A

there is a ccc-embedding A such that is well-pointed for all . preserves monic

A A F

cones. Moreover, if each is well-supported, then A can be chosen to be faithful, i.e. isomorphism- reflecting.

61

A A A I

Proof. We adjoin countably many arrows to each . More precisely, let be the directed poset

N A I CCC

of finite subsets X , ordered by inclusion. Let be the diagram that associates to each

x

x

i A

i A

n n  

A A X fhi A i hi A ig I CX C

n n n

a ccc , and to each inclusion

X Y I CX CY

the canonical ccc-representation . Notice that by Lemma 5.6,

A A

is a monic-preserving embedding, and moreover, if each is well-supported, then is faithful. We

CX

can take D to be the colimit of the diagram . Concretely, assume that each has the same objects as

C D

, and that the embeddings are actual inclusions on hom-sets. Then can be described as follows: the

C DB C CX B C

objects of D are those of , and the hom-set is the directed union of the hom-sets ,

I D F C D

where X . One checks that is a ccc and that the inclusion is a ccc-embedding preserving

F A D A A

collective monics, and moreover, is faithful if the are. To show that is well-pointed in , let

g A B D X I f g CX hi Ai X

and assume f in . Then there is with . Let and consider

x

iA

CX A f x g x A D iA : one has iA by Lemma 5.7. Hence is well-pointed in .

5.1.4 Henkin representation theorems A Henkin representation theorem characterizes those ccc’s which can be Henkin embedded in a given cate-

gory, or in a category from a given class. We consider Henkin representations into the category of non-empty

P

S S P sets S , into the category of sets , and into a category of presheaves over a poset . We will see in Section 5.3 how each of these target categories corresponds to a certain class of models of the simply-typed lambda calculus. The first one corresponds to Friedman’s set-theoretic models with non-empty types [21]; the second one corresponds to set-theoretic models with possibly empty types, as investigated by Meyer et al. [39], and the third one corresponds to Mitchell and Moggi’s Kripke models [42]. Our Henkin representation theorems will translate into completeness theorems for each of these classes of models. Representation Theorems for cartesian-closed categories have been considered in the papers of Cubri«ˇ c [14] and Simpson [60]. The difference to our representation theorems is that Cubri«ˇ c and Simpson work with strict ccc representations rather than Henkin representations, and they only consider representations of a free

cartesian-closed category.

Henkin representations in S

S A

Theorem 5.9. A small ccc C can be Henkin-embedded in if and only if for every object , the morphism

A is epic.

S A A

Proof. :In , one has for all ; moreover, embeddings reflect epics.

F

A

D F C D A jCj C

: Consider the ccc-embedding A from Proposition 5.8, with . Then

S is a Henkin-embedding.

C A A

Corollary 5.10. If for every object A in a small ccc , the morphism is epic and is well-supported,

C S then there is a faithful (i.e., isomorphism-reflecting) Henkin-embedding H .

Henkin representations in S

A A Definition. A cartesian-closed category C is called special if for every object , either the morphism

is epic, or A is partially initial. S

Theorem 5.11. A small ccc C can be Henkin-embedded in if and only if it is special.

S A A Proof. : The category is special, because each non-empty set satisfies , while the empty set

is (partially) initial. Moreover, embeddings reflect epics and partial initial objects, and hence specialness.

C F C D A

: Suppose is special. Consider the ccc-embedding A from Proposition 5.8, with

fA jCjjA g A D D A A

. Then each A is well-pointed in by construction of ; moreover, each is

F

A

D S partially initial and therefore trivially well-pointed. Hence C is a Henkin-embedding.

62 C

Corollary 5.12. Let M be a monoid, i.e. a one-object category. A small ccc can be Henkin-embedded in

M C

S if and only if is special.

M S

Proof. : is special, and embeddings reflect specialness.

M

H S S C

: There is an obvious ccc-embedding which preserves monics. If is special, it can be

M

S

Henkin-embedded in S and hence, by Remark 5.3 in .

I

C S

Corollary 5.13. Let I be a set. A small ccc can be Henkin-embedded in if and only if there is a family

T

C C

iI i i

i of ccc-congruences on such that each quotient is special, and such that is the

iI

identity relation.

A A A C

Remark. If a ccc C has an object such that is partially initial and , then is a preorder, i.e. every

B C

hom-set has at most one element. Indeed, if f g , then

f

B

C

A

g

g C C S

hence f . As a consequence, if has a non-trivial hom-set, then any Henkin embedding not

only reflects, but also preserves partial initial objects and epics A . P

Henkin representations in S

A S Any small ccc C can be ccc-embedded in a category of presheaves , for instance by the Yoneda embed-

ding (see Example 1.5). If one takes A to be a poset, it is still possible to obtain a Henkin embedding:

P

S P Theorem 5.14. Any small ccc C can be Henkin-embedded in for some poset . Moreover, the embed-

ding preserves monic cones.

F B A

B F A B S S S

Let A and be small categories, and let be a functor. This induces a functor ,

F F

which we denote by . Note that always preserves monic cones and limits, since these are taken pointwise

A B

S S F in and . The following two lemmas give sufficient conditions for to be a Henkin representation,

respectively, an embedding.

A B g FA B B f A A

Definition. A functor F is called left-full if for all in , there exists in

B FA g Ff

A such that and .

B A

F A B F S S

Lemma 5.15. If is left-full, then is a Henkin representation.

P F P

F Q F Q

Proof. We need to show that the canonical natural transformation is monic for

B

S A A

all P Q . Let . Unraveling the definition of exponentiation in a functor category yields that

B A

S BFA P Q S AA F P F Q f x Ffx

A A FA

A is given by ,

BFA P Q A A f A A x F P A P FA A

where , , and . To show that is

AFA P Q B B g FA B x PB

one-to-one, assume . Then there are , and such

g x g x F f A A A B FA g Ff

that B . Since is left-full, there is in such that and , B

hence

f x Ffx g x g x Ffx f x

A A FA B A A

B FA

A

A A

and therefore A . This shows that is one-to-one for every , hence is monic.

B A

F A B F S S

Lemma 5.16. If is onto objects, then is an embedding.

B

P Q S P Q B B A A PB QB

Proof. Let and . Then B for some . Let

B

B FA F F F F

A FA A

with . Then , hence . FA

63 Table 5.1: Typing rules for the simply-typed lambda calculus

(var)

x  x

(const)

 c

 M  N

(app)

 MN

()



x  M

(abs)

 x M

 M  N

(pair)

 hM N i

 M

(weaken)

 M

 M

( )

 M

 M

( )

 M

The proof of Theorem 5.14 now rests on the fact that every small category A is, in the terminology of Freyd

F P A and Scedrov [20], dominated by some poset P , i.e. there is a left-full functor which is onto

objects. P

Lemma 5.17 (Freyd, Scedrov [20]). Every small category A is dominated by some poset .

f

f f

n



A P A A

n

Proof. Let the objects of be finite sequences of objects and morphisms ,

F P A ordered by the prefix ordering. Then P is a poset, and the obvious functor is left-full and onto

objects.

op

C P Proof of Theorem 5.14: Let C be a small ccc. Then is dominated by some poset by Lemma 5.17;

op P

op C

F P C F S S

let . By Lemmas 5.15 and 5.16, the functor is a Henkin embedding; F

moreover it preserves monic cones. By precomposing with the Yoneda embedding, one obtains a Henkin

P

F Y C S

embedding .

5.2 The interpretation of the simply-typed lambda calculus

5.2.1 The simply-typed lambda calculus

tu

Let TC be a set of type constants . Simple types are given by the grammar:

t

V xy C

Let be an infinite set of variables . For each type , let be a set of individual constants

c d hTC C i . The collection is also called a simply-typed signature. Raw typed lambda terms

M N are given by the grammar:

M x c hM N i M M MN x M M

M

We have the usual notions of free and bound variables, and we write FV for the free variables of a

M Nx

term M . We identify raw terms up to renaming of bound variables, and we write for the result of

x M substituting N for in .

64 Table 5.2: Equational rules for the simply-typed lambda calculus

(refl)

 M M

(unit)

 M

 M N

(symm)

 N M

(proj )

 hM N i M

 M N  N P

(trans)

 M P

(proj )

 hM N i N

 M M  N N

(cong )

1

 hM N i hM N i

(surj)

 h M M i M

 M M (cong )

2

 M M

( )

 x M N M Nx

 M M (cong )

3

 M M

x M FV

( )

 x MxM

 M M  N N

(cong )

4

 MN M N

 M M

(add-var)

 M M

x  M M (cong )

5

 x M x M

x x x

m m

A type assignment is a finite, possibly empty sequence of pairs of a

x x i j j

variable and a type, such that i for all . We write if is contained in as a set.Avalid

 M

typing judgment is an expression of the form which can be derived by the rules in Table 5.1. An

 M N  M

equation of the simply-typed lambda calculus is an expression of the form , where

 N E E E E

and are valid typing judgments. If is an equation and is a set of equations, we write s

E E

if E can be derived from by the rules in Table 5.2. As usual, is called a theory if it is closed under

E E E E derivability, i.e. if s implies . The smallest theory of the simply-typed lambda calculus (for a

fixed signature) is denoted by . It is also called the pure theory.

5.2.2 Strict interpretation in a cartesian-closed category C

Fix a simply-typed signature. An (strict) interpretation I of the simply-typed lambda calculus in a ccc ,

C

which we schematically write as I , consists of an interpretation of types and an interpretation of

I

C  M

typing judgments. A type is interpreted as an object of . A valid typing judgment is

I

 M I interpreted as a morphism . A strict interpretation is uniquely determined by its values on

type constants and individual constants.

TC jCj C

Let I be an interpretation of type constants as objects of . This extends uniquely to an

I

interpretation of every type:

I

t I t

I

I I I

I

I I

I I I

x x I C

m m m

If is a type assignment, we write . Let

I

C be an interpretation of term constants as morphisms of , for each type . This extends uniquely to

65

I

 M

an interpretation of valid typing judgments:

j

I I I

 x j

j j

j , the th projection

c

I c

I I I

 c

c

I I I



I I

hM N i

I I I I I

 hM N i

I

M

I I I I I

 M

I

M

I I I I I

 M

I I

hM N i

I

I I I I I

 MN

I

x M

I

I I I I

 x M

Lemma 5.18. The interpretation of the simply-typed lambda calculus in a ccc has the following properties,

which are proved by induction on M :

f lg f mg M

1. Permutation of Individual Variables. If s is injective and FV

fx x g x x x x

sl m m s s sl sl

s , and if and then

I

M

I I

I

h i

s

sl

M

I

x x y y  M

m m l l

2. Term Substitution. Let and , and suppose and

 N j m M Nx N N

j n

j for . Let denote the simultaneous substitution of for

x x M n

in . Then

I

M Nx

I I

I I

I

h N N i

  n n

M

I

 M N I j M N

We say that an interpretation I satisfies an equation , in symbols, ,if

I I

 M  N E I j E I j E E E

.If is a set of equations, then we write if for all . The

I M

set of all equations that an interpretation I satisfies is written Th .If is a class of ccc’s, then we write

E j E E E I C M

M , for an equation and a set of equations , if for every strict interpretation in a ccc ,

j E I j E I implies .

Proposition 5.19. Soundness of the strict ccc interpretation.

E E Ej E CCC

s implies .

I C I j T I T C

If T is a theory and PL is an interpretation such that , then we also write .

I F

C C

An interpretation can be post-composed with a ccc-representation in an evident way: T is the

J I J I

F  M F  M interpretation J defined by and .

66

5.2.3 The cartesian-closed category associated to a theory

T F T

From a theory over a simply-typed signature, one constructs a cartesian-closed category ccc as fol-

f M

lows: The objects are simple types , and the morphisms M are named by terms such that

x  M M N T x  M

is a valid typing judgment. Two terms and name the same morphism if s

N .

F T

Proposition 5.20. The above construction yields a well-defined cartesian-closed category ccc . There is

I I

I T F T x  M f

ccc M

a canonical strict interpretation with and .

I J T C

Moreover, has the following universal property: For any strict interpretation , there is a unique

F F T C

ccc-representation ccc such that

T

J

I

F T

C

ccc

F

Corollary 5.21. Completeness of the strict ccc interpretation. Each theory T of the simply-typed lambda

calculus arises as the theory of some ccc-interpretation. Consequently, for any set of equations E ,

Ej E E E s

CCC implies .

5.2.4 Henkin representations of a free ccc Definition. The free ccc over a simply-typed signature is the cartesian-closed category associated to the pure

theory over that signature.

ˇ

A Cubri«c proved in [14] that for any object A in a free ccc, the unique morphism is epic, and hence the

condition of Theorem 5.9 is satisfied. The proof uses a strongly normalizing system of Mints reductions. Let

us remark here that, using these Mints reductions, one can show more about the morphism A :

Proposition 5.22. In a free ccc, the morphism A is a coequalizer of the diagram

A A

A

A B xA  M B f f

Proof sketch: Let f be named by the term , and assume . This

y A z A  M yx M zx M M

means s . Suppose is the unique normal form of with respect to the

yx M zx M yx

system of Mints reductions. Then M and are the respective unique normal forms of

zx M x f

and M , hence they are syntactically equal. It follows that does not contain freely, and therefore

M

B A

factors as A . We already know that the factorization is unique because .

A B B B As a consequence, in a free ccc, every object A is well-supported, i.e. for all . Indeed,

products preserve coequalizers, and coequalizers are covers. With Corollary 5.10, one gets:

Corollary 5.23. Any free ccc has a faithful (i.e. isomorphism-reflecting) Henkin-embedding into S .

5.2.5 The non-strict interpretation of the simply-typed lambda calculus

I C

Let C be a ccc. A non-strict interpretation of the simply-typed lambda calculus is a Henkin

I I I I

H F C H  M H  M

representation ccc . One defines and .

 M N I j  M N

A non-strict interpretation I satisfies an equation , in symbols ,if

I I

 N  M I I . As before, we denote by Th the set of equations that are satisfied in .

non-strict

E E j C M

For a class M of ccc’s we write if any non-strict interpretation in some that satisfies

M E E also satisfies . The following soundness theorem is an obvious consequence of Lemma 5.2:

67 Proposition 5.24. Soundness of the non-strict ccc-interpretation.

non-strict

E E E Ej

s implies .

CCC

Remark. Completeness is also evident, because the strict ccc-interpretations are among the non-strict ones. More interesting are completeness theorems with respect to certain smaller classes of models. This is the subject of the next section.

5.3 From Henkin representation theorems to completeness theorems 5.3.1 The problem with empty types

By a set-theoretic model of the simply-typed lambda calculus, we mean a non-strict interpretation in S .

The equational rules for the lambda calculus from Table 5.2 are not complete for equational reasoning in

I

set-theoretic models. This was first noticed by Meyer et al. in [39]. If in some model, the interpretation

of a type is the empty set, then the model satisfies every equation of the form

 M N

x (5.1)

I

On the other hand, if is non-empty, then the model satisfies the rule

 M N x M N x FV

(non-empty) (5.2)

 M N

for that type . (By this we mean, for every instance of the rule, if the model satisfies the premise, then it satisfies the conclusion. We also say the rule is sound for the model.) So in any particular set-theoretic model,

for each , either (5.1) or (5.2) holds. However, in a general theory of the simply-typed lambda calculus, this

is not true. Meyer and his co-authors give the following example: Let and be type constants, and let

f p x y x p x y y be an individual constant. Let and . Then the

following is sound for any set-theoretic interpretation:

x  fp fp

(5.3)

fp fp

I I

p p This is because, if is empty, then holds as a consequence of (5.1), while if is non-empty,

then (5.3) follows from (5.2). On the other hand, (5.3) is not sound for arbitrary theories of the lambda

calculus: specifically, let 2 be the poset with two elements , and consider the following interpretation

2

S

I : for types, we let

I I I I

fs s g ft t g fug

I I I I I

A

with the unique maps and . Let , and notice



fs s g

 

A Afs s g fs s g fs s g

that . Let be the first projection. Now define

I I I

f

via

t x

I

I if

f x f xu t

else,

I I

fp t t fp

With respect to this interpretation, . On the other hand, there is a unique

I I

x  fp fp I fp fp

morphism . Hence, holds for the interpretation , while does not. Consequently, the rule (5.3) is not admissible for arbitrary lambda theories. As the example shows, the equational rules in Table 5.2 are not complete for the class of set-theoretic models. On the other hand, the rule (non-empty) is sound only for set-theoretic models with non-empty types. Hence, the need arises to consider the following three classes of models, and their associated completeness theorems, separately:

68 1. One may consider set-theoretic models where all types are non-empty. This is the classical approach [21]. In this case, the rules in Table 5.2, together with (non-empty), are sound and complete.

2. One may consider all set-theoretic models. This necessitates a more elaborate system of inference rules. A sound and complete system was given in [39]. 3. One may enlarge the class of models to allow non-set-theoretic ones. The class of Kripke lambda models, introduced in [42], is a convenient such class, and for it, the rules in Table 5.2 are sound and complete. Each of the three classes of models can be described in terms of Henkin representations, and the completeness theorems in each of the three cases can be derived from the three respective Henkin representation theorems of Section 5.1.4.

5.3.2 A categorical analysis of the rule (non-empty)

I

We have already remarked that in a set-theoretic model, the rule (non-empty) is sound for a type if is

C

non-empty. More generally, if I is a non-strict interpretation of the simply-typed lambda calculus,

I I

I

and if is an object such that is epic, then the rule (non-empty) is sound for with respect to .

I I

M N x  M x  N

Because if x FV , and if , then, using Lemma 5.18,

I

M

I I I I

I

N

j M N T

and hence I . Conversely, assume that (non-empty) is sound for in some theory . Then

I

F T I is epic in the ccc ccc , for the canonical interpretation .

5.3.3 Set-theoretic models with non-empty types Fix a simply-typed signature. By a set-theoretic model with non-empty types of the simply-typed lambda

non-strict

I S Ej E calculus, we mean a non-strict interpretation . We write  for semantic consequence

non-empty S

E E E

with respect to that class of models. We write E if can be derived from the equations by the s

usual simply-typed lambda calculus rules, together with the rule (non-empty).

Theorem 5.25. Soundness and Completeness for non-strict interpretations in S . The rule (non-empty) is sound for non-strict interpretations in S . Moreover, any theory that is closed under (non-empty) arises from such an interpretation. As a consequence,

non-strict non-empty

E Ej E E

 if and only if .

s S

Proof. Soundness: It follows from the remarks in Section 5.3.2 that the rule (non-empty) is sound for

non-strict

j

 . S

non-strict

E j E T E

Completeness: Assume  . Let be the theory generated by and (non-empty). We need

S

E T I T F T A ccc

to show . Let be the canonical interpretation. Then for all objects of

F T H F T S ccc

ccc , hence there is a Henkin embedding by Henkin Representation Theorem 5.9.

I H I T S I I T I j EI j E E T Let . Then Th Th , hence .

5.3.4 Set-theoretic models with empty types

For reasoning about possibly empty types, we use the extended proof system of Meyer et al. [39]. Fix a

simply-typed signature. An emptiness assertion is an expression e , where is a type. We use the letter

to denote a sequence of emptiness assertions, and we write if is contained in as a set. An

69 Table 5.3: Rules for the simply-typed lambda calculus with emptiness assertions

(empty)

x  M N

e

 M N x  M N e

(cases)

 M N

 M N

(add-emp)

 M N

 M N  M  N extended equation is an expression of the form , where and are

valid typing judgments (note that no appears in typing judgments). The intuitive meaning of an extended

 M N  M N

k k

equation e e is: if through are empty, then holds. We

 E

freely use suggestive notation such as e to denote an extended equation whose left-hand side contains

x  E

an emptiness assertion e , and to denote an extended equation whose left-hand side contains a

E type assertion x , where may contain other emptiness or type assertions. We consider three special rules for extended equations, which are shown in Table 5.3. Notice that in the

ext

x M N E

rule (cases), the variable cannot be free in . We write E for derivability using these rules, s

together with the equational rules of the simply-typed lambda calculus. Throughout this subsection, we will E

write E for an extended equation, and for a set of extended equations. An extended theory is a set of

T

extended equations that is closed under derivability. If T is an extended theory, then we write for its

T subset of equations, i.e. those extended equations of T that contain no emptiness assertions. is a theory,

which we call the core of T .

A A A

Recall that a ccc C is special if for every object , either is epic or is partially initial. Let

C E

I be an interpretation of the simply-typed lambda calculus in a special ccc, and let be an

 M N I E I j E k

extended equation, say, e e . We say that satisfies , in symbols ,if

I I I I

 M  N k partially initial

non-strict

M Ej E Ej E I j E I j E

If is a class of special ccc’s, we write M , respectively ,if implies for

M M

all strict, respectively non-strict, interpretations I in a ccc in .

T

Definition 5.26. An extended theory T is called principal if for each type , either contains all extended

 E  E equations of the form x , or it contains all extended equations of the form e .

Proposition 5.27. The correspondence between principal extended theories and special ccc’s.

C

1. Let I be a strict or non-strict interpretation of the simply-typed lambda calculus in a special

fE j I j E g ccc. Then the set T is a principal extended theory.

2. Conversely, every principal extended theory arises in this way from some strict interpretation I .

Proof. 1.: First, we need to check that T is indeed an extended theory. It is easily checked that the rules C

(empty), (cases) and (add-emp) are sound with respect to any interpretation I in a special ccc . For (cases),

I

one uses the fact that C is special: the conclusion follows from the first premise if is partially initial,

I

T

and from the second premise if . The fact that is principal follows directly from the definition

I

j E T

of I : consider any type .If is partially initial, then contains all extended equations of the

I

 E T

form x .If is not partially initial, then (trivially) contains all extended equations of the form

 E

e .

T T

2.: Let T be a principal extended theory. Let be the core of , i.e. the subset of those extended equations

T C F T

of that contain no emptiness assertions. Let ccc be the cartesian-closed category associated

70

T I T C C

to the theory , and let be the canonical interpretation. We show that is a special ccc.

I

T x  E

Consider any object .If contains all extended equations of the form , then is partially

 E

initial. Otherwise, T contains all extended equations of the form e . Therefore, the first premise T

of (cases) always holds for the type , and hence the rule (add-emp) is sound for at type sigma. By the

I

C

remarks in Section 5.3.2 this means that . Therefore is special.

T j E I j E E E  E

k

We now claim that iff , for any extended equation . Let be e e ,

E E

where is an equation, i.e. contains no more emptiness assertions.

I I

T j E C k

First, assume . Assume that are partially initial in . Under this hypothesis,

I j E C T T x  E

i i we need to show . Since is the ccc associated to the theory , this implies that

ext

i k E T E

for . With , by repeated application of the rules (cases) and (add-emp), one gets . Since s

ext

E T E I j E

is a (non-extended) equation, it must be in the core, i.e. , hence .

s

T j E I j E T

Conversely, assume that . We claim that . Since is a principal extended theory and

ext

T T x  E j k E

, it must be the case that contains all extended equations of the form j , for each .

s I

ext ext

C T T E E j

Therefore, each is partially initial in . Also, from ,by(add-emp) one has , hence

s s

I j E I j E

. This shows that . The proof of the completeness result for set-theoretic models rests on the following lemma, which implies

that any extended theory is an intersection of principal ones: T Lemma 5.28. Maximal extended theories are principal. Let E be an extended equation and let be a

ext

E T

maximal extended theory such that T . Then is principal. s

Proof. Consider the following two hypothetical arguments:

ext

 E T Tfx  E g E

1.: If there is some extended equation x that is not in , then, by maximality, .

s

T fx  E g

Consider any derivation of E from . Alter this derivation by adding an emptiness assertion

e to each extended equation throughout. An inspection of the proof rules in Tables 5.2 and 5.3 shows that

ext

 Tf x  E g  E  T

this alteration yields a valid derivation of e e e , where e denotes

s

 E j E Tg the set of equations fe . Applying the rules (add-emp) and (empty) at the leaves, one

ext

 E

gets T e .

s

 E T 2.: If there is some extended equation e that is not in , then, by the same reasoning as in 1.,

ext

x  E

T . s

ext

T

Now observe that cases 1. and 2. cannot happen simultaneously, since otherwise E by (cases). It

s follows that T is principal.

Theorem 5.29. Soundness and Completeness for special ccc’s. Let CCCspec be the class of special ccc’s. Then

non-strict ext

E Ej E Ej E E

CCC iff iff . s spec CCCspec Proof. Soundness is an immediate consequence of the first part of Proposition 5.27. For completeness,

ext ext

E T E T E T

assume E . Let be a maximal extended theory containing such that . is principal by

s s

Lemma 5.28. By the second part of Proposition 5.27, it follows that T is the extended theory of some strict

I C I j E I j E E j E interpretation . Hence but , which implies CCCspec . Soundness and completeness for set-theoretic models now follows by applying the Henkin Representation

non-strict

Theorem 5.11. We write j for semantic consequence for extended equations with respect to set- S theoretic models.

Theorem 5.30. Soundness and Completeness for non-strict interpretations in S .

non-strict ext

E E E

Ej if and only if .

s S

ext

E

Proof. Soundness is a special case of Theorem 5.29. For completeness, suppose E . By Theorem 5.29,

s

C I C I j E I j E

there is a special ccc and a strict interpretation such that but . By Theorem 5.11,

H C S I H I S I

there is a Henkin embedding . Let . It follows from Remark 5.1.4 that

I validates the same extended equations as .

71

5.3.5 Kripke lambda models

P

S By a Kripke lambda model, we mean a a non-strict interpretation I in a presheaf category over

non-strict

Ej E

some poset P . We write Kripke for semantic consequence in the class of Kripke lambda models. P

Theorem 5.31. Soundness and Completeness for non-strict interpretations in S . Each simply-typed

P P lambda theory arises from some non-strict interpretation in a presheaf category S over some poset .As a consequence,

non-strict

Ej E E E Kripke if and only if s . Proof. Soundness is a special case of Proposition 5.24. Completeness is an immediate consequence of The-

orem 5.14.

5.3.6 A remark on the principal model property The class of set-theoretic models with non-empty types and the class of Kripke lambda models each have the principal model property: any lambda theory that arises from the class actually arises as the theory of

a single model. However, the principal model property does not hold for interpretations in S . Indeed, among the extended theories, the ones that arise from a single model are the principal ones in the sense of Definition 5.26—but not all theories are principal.

The reason for the failure of the principal model property lies with the categorical properties of S . Unlike

the category of non-empty sets, the category of sets does not embed its own discrete powers. Notice that any

I

S S

discrete power of the category of non-empty sets has enough points to be Henkin-embedded in

I

C S

via the point functor . As a consequence, a ccc can be Henkin-embedded in if and only

if it can be Henkin-embedded in S , and a lambda theory arises as the theory of a family of models with

non-empty types if and only if it arises as the theory of a single such model. A similar property holds for the P

class of Kripke lambda models, because any discrete power of a presheaf category S is again of this form.

What the proofs of Theorems 5.29 and 5.30 really show about set-theoretic models is that any extended I theory is the theory of some interpretation in a discrete power S of the category of sets. The proof is indirect, by first showing that any extended theory is an intersection of principal (namely, maximal) ones. In the process, the categorical meaning of the extended equations gets lost. Is it possible to give a more direct proof in the spirit of categorical logic, via a construction of a category directly from an extended theory?

This would be the ultimate form of Theorem 5.30. Presumably such a proof would require a categorical I

characterization of those ccc’s that can be Henkin-embedded in S . Unfortunately, the characterization

given in Corollary 5.13 is not very elegant, and a more satisfactory Henkin Representation Theorem for the I

class S is not known.

5.4 Henkin representations of PL-categories

5.4.1 PL-categories

CCC C jj CCC S Let U at and be the forgetful functors that map a small ccc to its underlying

category and to its set of objects, respectively.

hB Fi

Definition. A PL-category B consists of 1. a small base category B with finite products and a distinguished object ,

op

B CCC

2. a contravariant fiber functor F , together with a natural isomorphism

V jF j

V V

72

U F U F

V V

3. a natural transformation V , together with a natural isomorphism

C D F C D

VCD V V V

V

BFi

We sometimes write a PL-category as h if the remaining parts of the structure are understood.

Remarks. We assume that the finite products of the base category are chosen. We use the letters V W

B F V F

for objects of . The fiber functor maps an object to a cartesian-closed category V , called the fiber at

n

V F n F CD

. We also call the -fiber, and in particular, is called the 0-fiber. We use the letters for

f g F C D V

objects and for morphisms of the fibers, and we denote hom-sets of V by . Each morphism

V W F F F V B

W V

of the base gives rise to a ccc-representation of fibers . For an object ,

V V F F F

V V

let be the first projection. The resulting functor V is called the dummy

V

V V

V V V

functor at , and we denote it by V . Notice that , like , is natural in . Each has a right adjoint

F F

V V V V

V . Notice that is not assumed to be a ccc-representation. Both the functor and

a V V

V V

the adjunction V are assumed to be natural in . The naturality of in means that for all

C F D F V W

W

W and and for all ,

WCD

C D C D

W W W W

F F



(5.4)

C D C D

V V V V

VC D

C F C D F D

where and . In the literature on hyperdoctrines and universal quantification [55, 15],

V F F

W V

the condition that is natural in is sometimes relaxed: one only requires that and are

F F

V naturally isomorphic as functors W . In this case, condition (5.4) is replaced by the so-called

Beck-Chevalley condition. In our setting, the Beck-Chevalley condition and (5.4) are equivalent.

VD

D a D

V V V

The adjunction V can be described concretely in terms of its co-unit by the

C F g C D V

following property: for every object V and every morphism , there exists a unique

h g C D V

V such that

VD

D

D

V V

h

V

g

C V

In analogy to product diagrams and exponential diagrams (see Section 1.1.6), we call a diagram of the form

f

E D

V with the above universal property a -diagram. Condition (5.4) is equivalent to the requirement

F F V W D F

WD VF D W

that preserves -diagrams, i.e. for all and .

hB Fi B hB F i

Definition. Let B and be PL-categories. A PL-repre-

B Gi B B B B B

sentation h is a finite product preserving functor together with a natural

G F F B B V B C F D F

V

transformation , such that and for all , V , and :

V CD

V

V

C D C D

BV jF j

F

F

V V V V

V

V

V

G

G

jG j

V 

G

B V

G

V

V 

V

C D

C D

j jF

B BV

F

F

BV

BV BV

BV

BV

BV

BV

BV

BV C D

BV

C G C D G D G

V

where V and . The condition that preserves can be equivalently expressed in

G

VD

terms of -diagrams by requiring V . BV D

73

G B CCC G F F V

Notice that is a natural transformation of functors ; in particular, each V is a BV

ccc-representation. L Small PL-categories and PL-representations form a category, which we denote by P . We will now consider a notion of congruence relation on a PL-category. We are only concerned about

congruences on the morphisms of the fibers, and not on the morphisms or objects of the base. B

Definition. A PL-congruence on a PL-category is given by a family of equivalence relations on the

C D V B C D F

V V

hom-set of the fibers, i.e., an equivalence relation V CD on for each and , such

V F V

that for each , V is a ccc-congruence on (see Definition 5.1), and in addition:

f f

V CD

V

f f

V VC D V

V

hB Gi BB B f g

If is a PL-representation, then its kernel is a PL-congruence on , defined by VCD

G f G g f g C D

V V

iff V , for all .

B B

Conversely, let be a PL-congruence on . One can define the quotient by taking the quotient

C D V CD V at each hom-set of the fibers; one checks that this is a well-defined PL-category with the

same base category as B .

5.4.2 Henkin-PL-representations

hPMi P A pre-structure P consists of a base category with finite products and a contravariant functor

op

M P CCC V W P V W V

. For any pair of objects , we consider the first projection VW ,

M M M

V W

and the associated functor V , which we again call the dummy functor, and which we

VW

f

C D M

VW V W

denote by VW . We say that a diagram in is a partial -diagram if for every object

C M g C D h C C VW

V and every morphism , there exists at most one such that

f

C

D VW

h

VW

g

C

VW

B CCC H UF

A Henkin natural transformation between functors F G is a natural transformation

UG V B H

such that for each , V is a Henkin representation of ccc’s. Analogous to Henkin representations of cartesian-closed categories, we can now define Henkin represen-

tations of PL-categories:

hB Fi P hPMi

Definition. Let B be a PL-category and be a pre-structure. A Henkin-PL-

B H i BP B B P

representationh is a finite product preserving functor together with a Henkin

H UF UM B V B D F

natural transformation , such that for all and V ,

H

V  VD

H D H D H D

BV B V V V V V V H

is a partial -diagram. Notice that, by naturality of ,

H

V

F M

V BV

M

F

BV B B

V

V

V

F M

V BV B

H

V 

hB H i BP f g C D

Lemma 5.32. The kernel of a Henkin-PL-representation , defined for all V

f g H f H g B

V V by VCD iff ,isaPL-congruence on .

74

V B H F M

V BV V

Proof. For each , V is a Henkin representation of ccc’s, and hence is a ccc-

F C FV D FV f

V CD

congruence on V by Lemma 5.2. It remains to be seen that for and ,

V

f f f f C D H f H f f

VC D V V V V V

implies V . Suppose with . One has

V

H

V  VD

VD

H D

H D H D

BV B V V

D V V V V

D

V V

H f

H f

f

BV B V V

V  V V

V V

H f

f

V 

H C

C H C

BV B V

V V V

H f H f

V V

The top row is a partial -diagram, hence the arrow V is uniquely determined by . Since there

f H f H f H f H f

V V V V V

is an identical diagram for , and since V by assumption, one has .

B H i

Definition. We say that a Henkin-PL-representation h is a Henkin-PL-embedding if its kernel is the

H V B trivial congruence, i.e. if V is a Henkin embedding for each . Notice that we do not require to be an embedding of the base; it seems unnecessary to do so since we are only concerned with equality in the fibers.

5.4.3 Standard structures

e

D hS Mi

Consider a cartesian-closed category D. Let be the pre-structure , where the base category is the

X

S CCC X D X D category of sets, and the functor M maps a set to , the -fold power of . We call this

pre-structure the standard structure over D.

C S

For a ccc, we considered the point functor . We now consider an analogue to this functor

B hB Fi H F D

for PL-categories. Consider a PL-category , together with a functor .

hB H i B B S V

We define H , where is the point functor of the base category, mapping to

BV

BV H F M D

V BV

the hom-set , and V is the natural transformation defined on objects by

H C xH F C C F x BV V

x V

V , where and . The following proposition gives a sufficient

B H i

condition for h to be Henkin-PL-embedding.

e

B H i B D

Proposition 5.33. The pair h is a Henkin-PL-embedding if the following hold:

1. H is a Henkin embedding,

2. H preserves monic cones, and

F F F x V V B

V

3. the functors x , where , form a collective embedding for each .

B H H

Proof. Clearly preserves products and is natural. What remains to be shown is that each V is a Henkin

BV

H F C V

embedding, and that the condition on -diagrams is satisfied. First, notice that V factors as

F

V

H

V

F

x xBV

BV

BV

F

C

BV

H

F

xBV

Clearly, x is a ccc representation; by assumption 3, it is also an embedding. Assumption 1 im-

BV

H H V

plies that is a Henkin embedding, hence V is a Henkin embedding for every . Now suppose

VD

D D B V

V is a -diagram in . We need to show that

H

V  VD

H D H D H D

BV B V V V V V V

y BV is a partial -diagram. Unraveling the definitions, this amounts to showing that for each , the

collection of morphisms

H F

z C

H F C H C

z z

75

C F D H

is collectively monic, where y . Since preserves monic cones by assumption 2, it suffices to

C F

show that for every , the family

F

z C

F C C

z z

f g A C f g A C

is collectively monic. Let . Then . By assumption 3, there

z F f F g F f F g F id

z z C z C z F

is with z , i.e. . But , hence



F f F g

C z C z , which proves the claim.

5.4.4 Freely adjoining arrows to the base of a PL-category

hB Fi x U

Given a PL-category B , we may freely adjoin an arrow to the base as

T V U V B B

follows: Let B be the Kleisli category of the comonad , i.e. has the same objects as

op

B V W BU V W F B CCC F F

V

and (compare Section 5.1.3). Define by U ; this

V

V

V U V U VCD

is natural in . Define , U , , and . It is trivial to check

V V VCD

B hB F i F F

V U V U V

that is indeed a PL-category; for instance U

V

F F hB G i B B

V U V U V

is indeed right adjoint to U . Let be the natural

V

B G F F F x B U

V V V U V

PL-representation, defined by and . Let be

V

x

BU U B B U

id . We write as , which is justified by its universal property:

x

U hB Gi B

Proposition 5.34. B has the following universal property: for any PL-representation

x

BU D h B Gi B U D

D and any arrow in , there is a unique PL-representation such that

x

B U

B

hBGi

hBGi

D

and Bx .

id

V BV B V W BU V W BV

Proof. Let B map an object to and a morphism to

B

G BV BW

BU . Define by

V

F

D

BV

V

G

V

D

id

F D

U V BU BV

G

U V

It is readily checked that this is the unique PL-representation with the desired properties.

x

BB

Lemma 5.35. The canonical PL-representation is a PL-embedding.

x

B B

Proof. In B , there is always a point , for instance . The unique extension of

the identity that sends x to is a left inverse to .

B F

Proposition 5.36. Any PL-category B can be PL-embedded in a PL-category such that the functors

z

n

F F z n

n , where , form a collective embedding for each .



B B B B

Proof. To , adjoin countably many arrows by constructing a sequence of

x

i

B B n B

i i i

PL-categories, where i and is the canonical embedding. Notice that the -fiber of is

i B B

the n -fiber of . Let be the colimit of this sequence, i.e. the objects of the base are the same as for each B

i , and the hom-sets of the base and objects and hom-sets of the fibers are constructed as the directed unions

B B

of the respective parts of the i . It is easily checked that is a PL-category with a canonical PL-embedding

76

BB F F F

. To show that the functors n form a collective embedding, it suffices to show that

z

F F F x

for every V , the functors form a collective embedding, where . Consider two

V x V V

f g C D F C D f g B x i

morphisms in . Then , and already exist in some i . Consider

V

i

B F B

i

in i . Writing for the fiber functor of , one has

i

F

V

id

i

i

i

F

F

V

V

i

F

V x

i

i i

g f F F F f F V x g

i i

hence , which implies i .

V x

V x V x

i

i i

5.4.5 Henkin-PL-representation theorems

g

Henkin-PL-representations in S

A Lemma 5.37. If the 0-fiber of a PL-category has the property that A for every object , then the same

is true for any n-fiber.

c

n n

F F F F C D F

n n

Proof. Let be the right adjoint of the canonical functor . Let be

n

F f g D

objects of and consider such that

f

C D

g

f

n

D C

n n n

g

n

f

D

n n

g

f g

n n n

But both n and preserve terminators, hence and .

B

Theorem 5.38. Let B be a PL-category whose base is generated by . Then can be Henkin-PL-embedded

g

S A A in S , the standard structure over , if and only if for every object of the 0-fiber, the morphism

is epic.

g

B S F

Proof. : Trivial, because a Henkin-PL-embedding gives rise to a Henkin embedding

S , and embeddings reflect epics.

C B

: By Lemma 5.37, holds for all objects of all fibers. By Proposition 5.36, can be embedded

B F F V B F

in a PL-category such that the functors form a collective embedding, for every .

z

V

B i

Note that in the sequence of PL-categories i constructed in the proof of Proposition 5.36, the -fiber of

i

B n B C F F

i is the -fiber of . Hence, holds for all objects of , and therefore for all objects of as well.

F

A

H F F D S

By Theorem 5.9, there is a Henkin embedding . By Lemma 5.6, A preserves

monic cones, and so does the point functor . Therefore, Proposition 5.33 is applicable and we obtain a

g

S

Henkin-PL-embedding B .

g P

Henkin-PL-representations in S

g

P

B P Theorem 5.39. Any PL-category can be Henkin-PL-embedded in S , for some poset .

77

Table 5.4: Typing rules for the polymorphic lambda calculus

 M

(typeapp)

 M

 M FTV

(typeabs)

 M

Table 5.5: Equational rules for the polymorphic lambda calculus

 M M

(cong ) (B )

6

 M M  M M

 M M M FTV FTV

(cong ) (H )

7

 M M  MM

B B F F F

Proof. By Proposition 5.36, can be embedded in a PL-category such that the functors

z

V

B H

form a collective embedding, for every V . By Theorem 5.14, there is a Henkin embedding

P

S P H

F , for some poset , such that preserves monic cones. With Proposition 5.33, one obtains a

g

P

S Henkin-PL-embedding of B in .

5.5 The interpretation of the polymorphic lambda calculus 5.5.1 The polymorphic lambda calculus The polymorphic lambda calculus was independently introduced by Girard [22] and Reynolds [51]. Here, we

describe a version of the second order lambda calculus with surjective pairing and a unit type.

TC t u

Let TV be an infinite set of type variables , and let be a set of type constants .

Polymorphic types are given by the grammar:

t

V xy C

Let be an infinite set of individual variables . For each closed type , let be a set of individual

c d hTC C i constants . The collection is also called a polymorphic signature. Raw polymorphic

lambda terms M N are given by the grammar:

M x c hM N i M M MN x M M M

x M

As usual, the individual variable x is bound in the term . Moreover, the type variable is bound in

M M

the term and in the type . All other occurrences of variables are free, and we write FV for the

M M free individual variables and FTV for the free type variables of a term , as well as FTV for the free

type variables of a type . We identify types, as well as raw terms, up to renaming of bound variables. There

M

are three kinds of substitution: substitution of types in types , substitution of types in terms ,

Nx

and substitution of terms in terms M .

x x x

m m

A type assignment is defined as for the simply-typed lambda calculus.

 M m We write FTV FTV FTV . The valid typing judgments of the polymorphic

lambda calculus are derived by the rules in Tables 5.1 and 5.4. An equation is again an expression of the

 M N  M  N E

form , where and are valid typing judgments. If is an equation and

E E E E E

is a set of equations, we write p if can be derived from by the rules for the simply-typed lambda

78 calculus in Table 5.2, together with the one for the polymorphic lambda calculus in Table 5.5. E is called a theory if it is closed under derivability. The smallest theory of the polymorphic lambda calculus (for a fixed polymorphic signature) is denoted by PL.

5.5.2 Strict interpretation in a PL-category

Fix a polymorphic signature. A (strict) interpretation I of the polymorphic lambda calculus in a PL-category

I B

B , which we schematically write as PL , consists of an interpretation of types and an interpretation

of typing judgments, both relative to a sequence

I

n

al pha fg F

n of type variables. A type with FTV is interpreted as an object of . A valid

I

n

 M M fg  M F

typing judgment with FTV is interpreted as a morphism of .

Like for the simply-typed lambda calculus, an interpretation I is uniquely determined by its values on type

constants and individual constants.

I TC jF j

Let be an interpretation of type constants as objects of the 0-fiber. This extends uniquely

I

V jF j V

to an interpretation of every type. Recall that is the natural isomorphism V ,

 n

n

e

c

n

F F F and that is the ccc-representation induced by the unique morphism . We assume

that bound variables are renamed as necessary.

I n

n

i

i i

i , where is the th projection

I

c

t F I t

I

I I I

I

I I



I I

n

C F V

If is any object of V , then it corresponds, via , to a morphism of the base . The morphism

hid i V V F F F C

V V V V

id i

gives rise to a functor h , which we denote by . We call V this functor the substitution functor. Lemma 5.40. The following are properties of the interpretation of polymorphic types:

1. Permutation of Type Variables. The interpretation is independent of the ordering of the free type vari-

f kg f ng

ables, or of the addition of dummy variables, in the following sense: If s

f g

sk

is injective and FTV s , then

I I

F

h i

s

sk

 n s

sk

I I

n

In particular, if FTV , then .

fg f g

2. Type Substitution. For all types and with FTV and FTV ,

I I I

n

C F F id C D

V V F V VD V V

id i

Notice that h . Therefore, applying to the co-unit

V V

V

D C D D

V D V yields a natural transformation inst V CD , which will be useful for the interpretation

of type application.

I I I

x x I C

m m m

If is a type assignment, we write . Let

I

be an interpretation of term constants as morphisms of the 0-fiber, for each closed type . This

79

I

 M

extends uniquely to an interpretation of valid typing judgments:

j

I I I

 x j

j j

j , the th projection

c

b

F I c

I I I

 c

c

I I I



I I

hM N i

 

I I I I I

 hM N i

I

M



I I I I I

 M

I

M



I I I I I

 M

I I

hM N i

I

 

I I I I I



 MN

I

x M

I



I I I I



 x M

I

M

 inst

I I I I I I

n n

 M

I

n

M





I I I I

n

 M

Lemma 5.41. The interpretation of the polymorphic lambda calculus in a PL-category, defined inductively

as above, has the expected properties:

f kg f ng

1. Permutation of Type Variables. If s is injective and the free type

M f g

sk

variables FTV s , then

I I

 M F  M

h i

s

sk

 n s

sk

f lg f mg M

2. Permutation of Individual Variables. If s is injective and FV

fx x g x x x x

sl m m s s sl sl

s , and if and then

I

M



I I

I

h i

s

sl

M



I

M f g fg

3. Type Substitution. Whenever FTV and FTV , then

I I I

n

 M  M

x x y y  M

m m l l

4. Term Substitution. Let and , and suppose and

 N j m j

j for . Then

I

M Nx



I I

I I

I

h N N i

  n n

M

 



I

 M N I j M N

As usual, we say that an interpretation I satisfies an equation , in symbols

I I

 M  N MN

,if . This notion is independent of , as long as FTV .We

j M Ej E M

write M for semantic consequence in a class of PL-categories, meaning if all interpretations

E E in a PL-category in M that satisfy also satisfy .

80

Proposition 5.42 (Seely [56]). Soundness.

E E Ej E

PL

p implies .

I B I j T I T B

If T is a theory and PL is an interpretation such that , then we also write .

I G

B B

An interpretation can be post-composed with a PL-representation in an evident way: T is the

J I J I

G  M G  M

interpretation J defined by and .

5.5.3 The PL-category associated to a theory

F T hB Fi

From a theory T over a polymorphic signature, one constructs a PL-category PL

x

as follows: Fix an enumeration of type variables, and fix an individual variable . The base

n k

k

B has countably many objects, which we denote ; the hom-set is given by all -

h i f g

k k n tuples of polymorphic types with FTV . Composition is given by

substitution:

h i h i

 

k l

n k l

h i

i i l i i

n

i k k

where i denotes the simultaneous substitution of for . The identity at is

h i n

. One checks that the base has finite products.

n

n

n jF j

The objects of the -fiber are defined via , i.e. they are polymorphic types with

n

f g f n M

n M

FTV . The morphisms of the -fiber are named by terms such that

x  M M N T x  M

is a valid typing judgment. Two terms and name the same morphism if p

N . Just as in the construction of the ccc associated to a simply-typed theory (see Section 5.2.3), one checks

n k

F

that F is indeed cartesian-closed. The action of on morphisms of the base is as follows:

F f f

i i M

i M

h maps objects to and morphisms to . This defines a ccc-representation

 i i

k

n n n n

F F

k

n

. Notice that . The right adjoint acts on objects as . The

n n n

n

f f

M M n

adjunction is given by .

n

T

Proposition 5.43 (Seely [56]). The above construction yields a well-defined PL-category F PL . There is

I I

I T F T x  M f

a canonical strict interpretation with and M .

PL

I J T B

Moreover, has the following universal property: For any strict interpretation , there is a unique

F T B

PL-representation G PL such that

T

J

I

F T

PL B

G

Corollary 5.44. Completeness of PL-categories for the polymorphic lambda calculus. Each theory T of

the polymorphic lambda calculus arises as the theory of some strict interpretation in a PL-category. Hence,

Ej E E E

L p

P implies .

5.5.4 The non-strict interpretation of the polymorphic lambda calculus

I P

A non-strict interpretation of the polymorphic lambda calculus in a pre-structure P , denoted PL ,

I

I I

H F P H  M

is a Henkin-PL-representation PL . One defines and

PL I

non-strict

E H  M I j E Ej

. The notations , as well as , have their usual meanings. The following M Soundness Theorem is a consequence of Lemma 5.32. Again, completeness is evident, since the class of non-strict interpretations includes the class of strict ones.

81 Proposition 5.45. Soundness of the Non-Strict Interpretation.

non-strict

E E Ej E

p implies .

PL

e

A non-strict interpretation of the polymorphic lambda calculus in a standard structure D is called a standard

S

model. The case D gives rise to set-theoretic models with non-empty types which are closely related

P

S

to the environment-style models that were described by Bruce and Meyer [10]. The case D gives rise

S to polymorphic Kripke models. Finally, the case D gives rise to set-theoretic models of polymorphism with possibly empty types. We will leave the discussion of the latter class of models for elsewhere.

5.6 From Henkin-PL-representation theorems to polymorphic com- pleteness theorems 5.6.1 Set-theoretic models with non-empty types

A set-theoretic model of polymorphism with non-empty types is a non-strict interpretation in the standard g

non-strict

j

structure S . Write for semantic consequence with respect to this class of models.

g

 S Theorem 5.46. Soundness and Completeness for set-theoretic models of polymorphism with non-emp- ty types. The rule (non-empty) is sound for set-theoretic models of polymorphism with non-empty types. Moreover, any theory that is closed under (non-empty) arises from such an interpretation. Consequently,

non-strict non-empty

Ej E E

E if and only if .

p

g

 S

Proof. Soundness follows from Lemma 5.37 and the remarks in Section 5.3.2. For completeness, let T be

I T F T

a theory that is closed under (non-empty). Let PL be the canonical interpretation. Because

of the rule (non-empty), one has C for all objects of the base, hence, by Theorem 5.38, there is a

g

H F T S I H I T

Henkin-PL-embedding PL . Then the interpretation satisfies exactly .

5.6.2 Polymorphic Kripke models

g

P S A polymorphic Kripke model is a non-strict interpretation in a standard structure where P is a poset.

non-strict Semantic consequence for this class of models is denoted by j Kripke . Theorem 5.47. Soundness and Completeness for polymorphic Kripke models. Each polymorphic lamb- da theory is the theory of some polymorphic Kripke model. Therefore,

non-strict

Ej E E E Kripke if and only if p .

Proof. This is a direct consequence of Theorem 5.39.

82 Chapter 6

First-Order Axioms for Asynchrony

The distinction between synchronous and asynchronous communication is a relevant issue in the design and analysis of distributed and concurrent networks. Intuitively, communication is said to be synchronous if messages are sent and received simultaneously, via a ‘handshake’ or ‘rendez-vous’ of sender and receiver. It is asynchronous if messages travel through a communication medium with possible delay, such that the sender cannot be certain if or when a message has been received. Asynchronous communication is often studied in the framework of concurrent process paradigms such

as the asynchronous -calculus, which was originally introduced by Honda and Tokoro [26], and which was independently discovered by Boudol [9] as a result of his work with Berry on chemical abstract machines [8]. Another such asynchronous paradigm is the join calculus, which was recently proposed by Fournet and Gonthier as a calculus of mobile agents in distributed networks with locality and failure [17, 18]. In this chapter, we study properties of asynchronous communication in general, not with regard to any particular process calculus. We give a general-purpose, mathematically rigorous definition of asynchrony, and then we show that this notion can be equivalently characterized by a small number of first-order axioms. We model processes by labeled transition systems with input and output, a framework that is sufficiently

general to fit concurrent process paradigms such as the -calculus or the join calculus, as well as data flow models and other such formalisms. These transition systems are similar to Lynch and Stark’s input/output automata [35], but our treatment is more category-theoretic and close in spirit to Abramsky’s interaction categories [1, 2]. Various properties of asynchrony have been exploited in different contexts by many authors. For instance, Lynch and Stark [35] postulate a form of input receptivity for their automata. Palamidessi [45] makes use

of a certain confluence property to prove that the expressive power of the asynchronous -calculus is strictly

less than that of the synchronous -calculus. Axioms similar to the ones that are presented here have been postulated by Shields [59] and Bednarczyk [6] for a notion of asynchronous labeled transition systems, but without the input/output distinction which is central to the present approach. The main novelty of our approach is that the axioms are not postulated a priori, but derived from more primitive notions. We define asynchrony in elementary terms: an agent is asynchronous if its input and/or output is filtered through a communication medium, such as a buffer or a queue, possibly with feedback. We then show that our first- and second-order axioms precisely capture each of these notions. This charac- terization justifies the axioms a posteriori. As a testbed and for illustration, we apply these axioms to an asynchronous version of Milner’s CCS, and to the core join calculus.

6.1 An elementary definition of asynchrony

R R

If R is a binary relation, we write for the inverse relation and for the reflexive, transitive closure of

R . We also write for , etc. The binary identity relation on a set is denoted . The composition of

Q R Q RQ xR Qz y xR y Qz two binary relations R and is written or simply , i.e. if there exists such that .

83

fy jxR y g Ry fxjxR y g X

We write xR for the unary relation , and similarly for . The disjoint union of sets

X Y and Y is denoted by .

6.1.1 Labeled transition systems and bisimulation To keep this chapter self-contained, we summarize the standard definitions for labeled transition systems and

weak and strong bisimulation.

S hS A s i S A

Definition. A labeled transition system (LTS) is a tuple S , where is a set of states, is

S A S s S A

a set of actions, S is a transition relation and is an initial state. We call the type

S A

of S, and we write .

jSj S A

We often omit the subscript on S , and we write for the set of states .For , we regard as a

Sj s s hs s i binary relation on j via iff . The definitions of strong and weak bisimulation rely on

the following principle of co-inductive definition:

P X P R

Principle 6.1. Let X be a set and a property of subsets of .If is defined by clauses of the form

F R G R F G F P

i i i i

i , where and are set-valued, monotone operators, and if preserves unions, then is

R X P R max

closed under unions. In particular, there is a maximal max with .

F F P R iF R G R

i i

Proof. Since i preserves unions, it has a right adjoint . Then

i

T

R F G R P

i . Hence is the set of pre-fixpoints of a monotone operator and therefore closed under

i

i

S

R fR j P R g

least upper bounds. Let max .

T A R jSjjTj

Definition. Let S and be LTSs of type . A binary relation is a strong bisimulation if for

R A R R R

all , and . In diagrams:

s R sRt s R t sRt t

t s and

s t s Rt s Rt

A

Next, we consider LTSs with a distinguished action , called the silent or the unobservable action. Let

a a

a A n R jSjjTj

be the relation .For , let be the relation . A binary relation is a

A R R R R

weak bisimulation if for all , and . In diagrams:

s R sR s R sRt t t t

s and t

t s Rt s Rt s

By Principle 6.1, it follows that there is a maximal strong bisimulation, which we denote by , and a maximal

s jSj t jTj

weak bisimulation, which we denote by . We say that and are strongly (weakly) bisimilar

s t s t S T s t s t

if ( ). Finally, and are said to be strongly (weakly) bisimilar if ( ).

jSjjTj A R R

Remark. Note that R is a weak bisimulation if and only if for all , and

R

R .

T U R jSjjTj Q jTjjUj

If S are labeled transition systems and if and are weak (respectively,

jSjjSj R jTjjSj

strong) bisimulations, then so are the identity relation , the inverse , and the

Q jSjjUj composition R . Hence weak and strong bisimilarity each define a global equivalence relation

on the class of all states of all possible labeled transition systems.

S

In particular, and , as binary relations on an LTS , are equivalence relations. We denote the respective

a

t s s s S s

equivalence classes of a state by and . On the quotient , we define transitions

a a

s S s t t

iff , making it into a well-defined transition system. Similarly, on , we define iff

a

s t s S s s s s S S S S

. For all , one has and , and hence and . We say that

S S S S S is -reduced if , and -reduced if .

84 6.1.2 Input, output and sequential composition

So far we have distinguished only one action: the silent action . We will now add further structure to the Y

set of actions by distinguishing input and output actions. Let in and out be constants. For any sets X and ,

f gX Y f gY

define a set of input actions In X in , and a set of output actions Out out . Note that

Y x x h xi

In X and Out are disjoint. We will write input and output actions as in and out instead of in and

xi B x y

hout , respectively. Let be a set whose elements are not of the form in , out or . The elements of

f g

B are called internal actions.

X Y X Y B f g S

Definition. We define B to be the set In Out . A labeled transition system of type

X Y B X Y B

B is called an LTS, or simply an agent.If is empty, we will omit the subscript in .

x x x

The traditional CCS notation is “x” for input actions and “ ” for output actions. We use in and out instead x to emphasize the distinction between a message in x and its content . Our labeled transition systems with input and output are similar to the input/output automata of Lynch and

Stark [35]. However, we consider a notion of sequential composition that is more in the spirit of Abramsky’s

S X Y T Y Z S T X Z

B B

interaction categories [1, 2]. Given two agents B and , we define by T feeding the output of S into the input of . This is a special case of parallel composition and hiding. Notice

that this notion of sequential composition is different from the one of CSP or ACP, where T cannot start

execution until S is finished. Sequential composition, together with certain other agent constructors that we will investigate in Sec-

tion 6.3.1, can be used to build arbitrary networks of agents.

S X Y T Y Z s t

B

Definition 6.2. Let B and be agents with respective initial states and . The se-

S T X Z jSjjTj hs t i

quential composition is of type B . It has states and initial state . The transitions

are given by the following rules:

y

out y in

s s t t s s t t

S T T

not output not input S

hs ti hs ti hs ti hs t i hs ti hs t i

ST ST ST

X I X X X fg

Example 6.3. For any set , define an agent X of type with states , initial state and x

in x out

x x x X I transitions and , for all . X acts as a buffer of capacity one: A possible sequence

of transitions is

x y y z z

in x out in out in out

x y z

X fxg I I I

X X Let . Then X and are the following agents:

out x

h i hxi

in x

x

I I I

x x

X X

X in in

out x

hx i hx xi

out x

Here the initial state of each agent is circled. When representing agents in diagrams like these, it is often convenient to omit the names of the states, and to identify weakly bisimilar states. With that convention, we

write:

x x

in x in in

I I I

X X X

x x

out x out out

I I Y fy z g I

X Y Note that X is a queue of capacity 2. Let . The following diagrams represent and

85

I I Y

Y :

y

in out z

y y

y

z z

out z in out out in in

I I I

Y Y Y

y y y

z z

in z out in in out out y

out in z

I I Y

Again, Y is a queue of capacity 2. Notice that it is first-in, first-out.

T A jSj jTj Two LTSs S and of type are isomorphic if there is a bijection between and preserving and initial states.

Lemma 6.4. 1. Sequential Composition of labeled transition systems is associative up to isomorphism.

T

2. The following hold for the composition S :

y y

out in

s s t t

s s t t S

not output T not input

S T

hs ti hs ti hs ti hs t i

hs ti hs t i

ST ST

ST

3. Sequential Composition of agents respects both weak and strong bisimulation, i.e.

S S T T S S T T

and

S T S T S T S T

s tiui hhs t iu i hs ht uii hs ht u ii

Proof. 1. It is easy to check that hh if and only if .

y

out

s s s s

2. The first two statements are trivial from Definition 6.2. For the third one, assume

y

in

t t t t hs ti hs ti hs t i hs t i hs t i hs t i

and . Then .

S S X Y T T Y Z Q jS jjS j R jT jjT j

B B

3. Let and . Suppose and are weak

Q R fhhs t i hs t ii j s Qs t Rt gjS T jjS T j

bisimulations. We show that and is a

weak bisimulation. It suffices without loss of generality to show one of the two directions. Suppose

hs t i Q R hs t i

hs t i

X Z

for some B . There are three cases, depending on which of the three rules in Definition 6.2 was

hs t i hs t i

used to derive :

s s t t Q s s s s t Qs t

Case 1: , and is not output: By there is such that and . Let .

t t s s R t t t t s Rt s

Case 2: , and is not input: By there is such that and . Let .

y y

out y in out

Qs s s t t Q R s t s s s

Case 3: , and :By and , there are and such that , ,

in y

t Rt t t

and .

In each case, by 2.,

hs t i Q R hs t i

hs t i Q R hs t i

For strong bisimulation, the proof is similar. Unfortunately, agents do not form a category under sequential composition: there are no identity morphisms. In Section 6.1.4, we will introduce two categories of agents, one of which has unbounded buffers as its identity morphisms, and the other one queues.

86

6.1.3 Buffers and queues

X X X

For any set X , let be the free monoid and the free commutative monoid generated by . The

X

elements of X are finite sequences. The empty sequence is denoted by . The elements of are finite

X X

multisets. The empty multiset is denoted by . We define the following agents of type B : x

in x out

B X w wx xw w

1. The buffer X has states , initial state , and transitions and , for all

X x X

w and . x

in x out

Q X w wx xw w

2. The queue X has states , initial state , and transitions and , for all

X x X

w and .

B Q X

The only difference between the definitions of X and is whether the states are considered as sequences

Q X B or multisets. We will write B and without subscript if is clear from the context. acts as an infinite capacity buffer which does not preserve the order of messages. For example, one possible sequence of

transitions is

y z y x w

in x in in out out in

x xy xy z xz z wz

Q acts as an infinite capacity first-in, first-out queue. A possible sequence of transitions is

y x z w y

in x in out in in out

x xy y yz yz w zw

BB B B B

Lemma 6.5. 1. B and .

Q Q Q Q Q

2. Q and .

BB Q B B

3. Q and .

X j B Q B B Q Q

4. If j , then and .

u v iRw vu w u v w Proof. 1.-3.: Define h iff , where , and are multisets or sequences, as appropriate. In

each case, R is a weak bisimulation. To see that strong bisimilarity does not hold, observe that in each case, Q

the composite agent has silent actions, while B and do not.

y y x

in x in out out

B Q s s s

4.: Observe that has a transition from its initial state such that is possible, y

out x out

s B Q but is not. This is not the case for either or . Such properties are preserved under weak

bisimulation. The remainder of this chapter is devoted to examining the effect of composing arbitrary agents with buffers and queues.

6.1.4 Notions of asynchrony In the asynchronous model of communication, messages are assumed to travel through a communication medium or ether. Sometimes, the medium is assumed to be first-in, first-out (a queue); sometimes, as in the

asynchronous -calculus, messages might be received in any order (a buffer).

Our approach is simple: we model the medium explicitly. An asynchronous agent is one whose output Q

and/or input behaves as if filtered through either a buffer B or a queue .

S X Y

Definition 6.6. An agent B is

S B S S Q

out-buffered if S out-queued if

B S S Q S

in-buffered if S in-queued if

B S B S Q S Q buffered if S queued if

We use the word asynchrony as a generic term to stand for any such property. The reason we distinguish six different notions is that, although it is probably most common to think of asynchrony as part of the output

87 behavior of an agent, it is equally sensible to regard it as part of the input behavior, or both. Since input and output behave somewhat differently, we will study them separately. Yet another notion of asynchrony,

incorporating feedback, will be defined in Section 6.3.2. Q

Remark. Because of Lemma 6.5, the operation of pre- or post-composing an agent with B or is idempotent

S B B S up to . Consequently, any agent of the form is out-buffered, any agent of the form is in-buffered, an agent is buffered iff it is in- and out-buffered, and so on. Also, each of the six properties is invariant under

weak bisimulation.

S B B S Notice that it is almost never the case that an agent S is strongly bisimilar to or to . This will be clear from the examples in Section 6.1.5. Weak bisimulation appears to be the finest equivalence relation that is sensible for studying asynchrony. It is also possible to consider coarser equivalences; the results of this chapter generalize in a straightforward way to any equivalence on processes that contains weak bisimulation;

see Remark 6.12.

B S X Y B

Let be a set. Buffered agents B form the morphisms of a category Buf , whose objects are sets

X Y X B

, , etc.; the identity morphism on is given by the buffer X . Similarly, queued agents form a category

QueB . These categories have a symmetric monoidal structure, which will be described, along with other constructions on agents, in Section 6.3.1.

6.1.5 Examples

Example 6.7. The first example shows the effect of post-composing different agents with the buffer B . Notice

S B

that although B has infinitely many states, may have only finitely many states up to weak bisimulation. y

out y out

hs i hs y i

hs y i

s

out y

out y y

out y out

x x

S B S

t in in

fy g

ht i ht y i

ht y i

in x

y

x x

in x in in out

u y

out y out

hu i hu y i

hu y i

Example 6.8. y

out y out

z

out

S B S x in x in

out z

Example 6.9. Here is an example on in-bufferedness. Notice that an input action is possible at every state of

S

B . x

in

out y y

in x out

in x

x x

B S

S in in

fxg z

in x out

out z

x in

88

Table 6.1: First-order axioms for out-buffered agents

y y y

out y out out out

s s s

s

s s s

s

y

out y out

t t t

s s s

y where out output-commutativity (OB1) output-confluence (OB2)

out y

s

s

s s

out y

s

output-determinacy (OB3)

6.2 First-order axioms for asynchrony

In this section, we will give necessary and sufficient conditions for each of the notions of asynchrony from Definition 6.6. These conditions are in the form of first-order axioms, by which we mean axioms that use quantification only over states and actions, but not over subsets of states or actions. The axioms, which are shown in Tables 6.1 through 6.4, characterize each of our notions of asynchrony up to weak bisimulation; this means, an LTS is asynchronous iff it is weakly bisimilar to one satisfying the axioms. It is possible to lift the condition “up to weak bisimulation” at the cost of introducing second-order axioms; this is the subject of Section 6.6.

6.2.1 Out-buffered agents Table 6.1 lists three axioms for out-buffered agents. We use the convention that variables are implicitly existentially quantified if they occur only on the right-hand-side of an implication, and all other variables are implicitly universally quantified. Thus the axioms are:

(OB1) Output-commutativity: output actions can always be delayed.

(OB2) Output-confluence: when an output action and some other action are possible, then they can be per-

formed in either order with the same result. In particular, neither action precludes the other.

y y Y (OB3) Output-determinacy: from any state s, there is at most one transition out for each . Each of these axioms is plausible for the behavior of a buffer. Output-determinacy is maybe the least intuitive of the three properties; the idea is that once an output action is stored in a buffer, there is only one way of

retrieving it. Together, these axioms characterize out-bufferedness up to weak bisimulation:

S T Theorem 6.10 (Characterization of out-buffered agents). An agent S is out-buffered if and only if

for some T satisfying (OB1)–(OB3). This is a direct consequence of the following proposition:

Proposition 6.11.

B

1. Every agent of the form S satisfies (OB1)–(OB3).

S S B 2. If S satisfies (OB1)–(OB3), then .

89

Table 6.2: First-order axioms for in-buffered agents

x x

in in

s

s

s s

s

s

s s

x x

in x in in

in x

t t

s

t

s s

input-commutativity (IB1) input-confluence (IB2)

in x

s s

in x

s s t

s s

in x

input-receptivity (IB4)

s

input-determinacy (IB3)

Table 6.3: First-order axioms for out-queued agents

y y y

out y out out out

s s s

s

s s s

s

y

out y out

t t t

s s s where not output where not output output-commutativity’ (OQ1) output-confluence’ (OQ2)

out y

s

s

y z

out z and

s s

s

output-determinacy’ (OQ3)

Table 6.4: First-order axioms for in-queued agents

x

in x in

s

s

s s

s

s

s s

x x

in x in in

in x

t t

s

t

s s where not input where not input input-commutativity’ (IQ1) input-confluence’ (IQ2)

in x

s s

in x

t s s

s s

in x

input-receptivity (IQ4)

s

input-determinacy (IQ3)

90 Proof. 1. Clearly, the buffer B satisfies (OB1)Ð(OB3). Moreover, these conditions are preserved by arbitrary

sequential composition from the left. We show this for (OB1); the other cases are similar. Suppose B satisfies

B (OB1). To show that S satisfies (OB1), consider transitions

out y

hu si hu s i

hu ti

out y

s B hu s i hu ti

Then s in . By Definition 6.2, there are three cases for :

t u u

Case 1: s , , not output.

out y

u u s t s s s t

Case 2: , , not input. Hence, by hypothesis there is such that .

x x y

out x in in out

u u s t s s s t Case 3: , , . Hence, by hypothesis there is such that . In each of the three cases, the diagram can be completed:

Case 1: Case 2: Case 3:

y y

out y out out

hu si hu ti hu si hu s i hu si hu s i

y y

out y out out

hu si hu ti hu s i hu ti hu s i hu ti

out w

t S X Y w y y y Y s

n

2. Suppose B satisfies (OB1)Ð(OB3). For any sequence , we write

y y y w

 n

out  out out out

t t n w Y w s

if s ( ). Note that if is a permutation of , then iff w

out w out

t t R jSjjS Bj sR ht w i s R s by (OB1). Consider the relation given by iff . Clearly, relates

initial states. We show that R is a weak bisimulation. In one direction, suppose

s R ht w i

s

Two cases arise:

w

out y out

y y w R s w yw s t

Case 1: out for some . By the definition of , , where .By(OB3),

s s R ht w i ht w i ht w i X

we have s . Therefore , and also .

w w

out out

t t y y w s s s s t t

Case 2: out for all . From and ,weget and by repeated

R ht wi ht w i ht wi

application of (OB2). Therefore s and (notice the use of here, which is necessary X in case is an output action).

In the other direction, suppose

s R ht w i

ht w i

t w i ht w i

We distinguish three cases for h , depending on which rule in Definition 6.2 was used.

w

out w out

t t w w s s s t t t

Case 1: , and not output. Then , which implies by

s R ht wi X

repeated application of (OB1), i.e. s .

t w w B y

Case 2: t , and not input. Since has only input and output transitions, must be out for

w

out y out

y Y w yw s s s R ht w i X s t some with . Then , i.e. .

91

y w y

out y in out out

t w w w wy s t t

Case 3: t , and . In this case, and , hence

ht w i X sR .

Remark 6.12. Theorem 6.10 generalizes to other notions of equivalence of processes, as long as they are

coarser than weak bisimulation. Indeed, if is an equivalence of processes such that , then for any

S T S T T S T agent , there exists some out-buffered with iff there exists satisfying (OB1)Ð(OB3) and . This is a trivial consequence of Theorem 6.10. Similar remarks apply to the other results in this section and in Section 6.3.

6.2.2 In-buffered agents The axioms for in-buffered agents are listed in Table 6.2. The main difference to the out-buffered case is the property input-receptivity: an in-buffered agent can perform any input action at any time. This was illustrated in Example 6.9. The input/output automata of Lynch and Stark [35] have this property, and so does Honda

and Tokoro’s original version of the asynchronous -calculus [26]. Remark. Somewhat surprisingly, the axioms in Table 6.2 are not independent. In fact, (IB1) and (IB2) are equivalent in the presence of (IB3) and (IB4). We present all four axioms in order to highlight the analogy to

the output case.

S T Theorem 6.13 (Characterization of in-buffered agents). An agent S is in-buffered if and only if for

some T satisfying (IB1)–(IB4). This is a consequence of the following proposition:

Proposition 6.14.

S

1. Every agent of the form B satisfies (IB1)–(IB4).

S B S 2. If S satisfies (IB1)–(IB4), then . Proof. The proof is much like the proof of Theorem 6.11. We give the details of 2. to demonstrate how each of the properties (IB1)Ð(IB4) is used.

in w

t S X Y w x x x X s

n

2. Suppose B satisfies (IB1)Ð(IB4). For any sequence we write

x x x w

 n

in  in in in

t t n w X w s

if s ( ). Again, notice that if is a permutation of , then iff w

in w in

t t R jB SjjSj hw siRt s R s by (IB1). Consider the relation given by iff . relates initial

states, and we show that it is a weak bisimulation. In one direction, suppose

hw si R t

t

in w

s hw si hti ht i ht iRt t Then , hence . But clearly .

In the other direction, suppose

hw si R t

hw s i

We distinguish the usual three cases by Definition 6.2.

s w w x x X w wx

Case 1: s , and not output. In this case, in for some with .By x

in w in

t t s hw siRt X

definition of R , , hence .

w

in

s w w s s s t t t Case 2: s , and not input. To and repeatedly apply (IB2) to get and

in w

s hw s iRt X t

, hence .

x x w

out x in in in

w s s t s w xw s s s

Case 3: w , and . Then and . But by (IB3), ,

in w

t hw s iRt X hence s , therefore .

92 6.2.3 Out-queued and in-queued agents The results for buffers are easily adapted to queues. The relevant properties are given in Tables 6.3 and 6.4. Notice that the conditions for commutativity and confluence differ from the respective rules in the buffered case only in their side conditions. Different outputs (respectively, different inputs) no longer commute or conflow. Output-determinacy is strengthened: from each state, there is at most one possible output transition. Note that (IB1)Ð(IB4) imply (IQ1)Ð(IQ4). This is due to the fact that every in-buffered agent is also in- queued as a consequence of Lemma 6.5(3). On the other hand, no implication holds between (OQ1)Ð(OQ3)

and (OB1)Ð(OB3), since out-bufferedness and out-queuedness are incomparable notions due to Lemma 6.5(4). Just like in the buffered case, the axioms for input are not independent: we have (IQ1) (IQ2) in the presence of the other axioms.

Theorem 6.15 (Characterization of in- and out-queued agents). An agent S is out-queued if and only if

T T S S T T S for some satisfying (OQ1)–(OQ3). Moreover, is in-queued if and only if for some

satisfying (IQ1)–(IQ4).

6.3 More agent constructors and asynchrony with feedback 6.3.1 Some operations on agents In this section, we will introduce some operations on agents, such as renaming and hiding of actions, parallel

composition and feedback.

A A A S

1. Domain extension. If S is an LTS of type , and if , then can also be regarded as an LTS of

type A .

S A A A Sj

2. Domain restriction (hiding). If is an LTS of type , and if , then A is defined to be

S S

the LTS of type A which has the same states as , and whose transitions are those of restricted to

SjA jSj

j .

S X Y f X X g Y Y

3. Composition with functions. Let B , and let and be functions. By

f S g X Y S

we denote the agent of type B with the same states as , and with input transitions

x fx gy y

in in out out

t t t t s s s s s t

f Sg S f Sg S Sg

if , output transitions if , and with f iff

s t

S when is an internal action.

Domain extension, domain restriction and composition with functions are special cases of the following,

general renaming construct:

A r A A

4. General renaming and hiding. Let S be an LTS of type and let be a relation such that

r S A S

iff . Define r to be the LTS of type that has the same states and initial state as and

s t s t r S

transitions S iff for some . r

Let us now turn to various forms of parallel composition.

T A SkT

5. Parallel composition without interaction. Let S and be LTSs of type . Then is the LTS of type

A jSjjTj hs t i

with states and initial state , and whose transitions are given by the rules

t t s s

T S

hs ti hs ti hs ti hs t i

SkT SkT

X X S X Y

6. Symmetric monoidal structure. Let be the disjoint union of sets. For B and

T X Y S T X X Y Y S kT r q

B r q

B , define to be the agent , where and are the

Y Y Y X Y X X X

B B

inclusions of B , respectively into . Then defines a symmetric monoidal structure on the categories Buf and Que. The tensor unit is given by the agent I of type with one state and no transitions.

93 The constructors we have considered so far, including sequential composition, are not sufficient to build arbitrary networks. What is missing is the ability to construct loops. The next constructor allows the output

of an agent to be connected to its own input:

S X Y O Y X S O

7. Self-composition (feedback). Let B . Let be a set of pairs. Define , the

S O X Y

self-composition of along ,tobetheLTS of type B whose states are identical with those of

S, and whose transitions are given by the rules

x

out y in

s t

s t hy xiO

S

S

s t

s t

SO

SO

S X X O fhx xijx X g S

In the common case where B and , we will write instead of

O S . We can use self-composition to define both sequential and parallel composition. 8. Sequential composition. The sequential composition of agents was defined in Definition 6.2. Alter-

natively, one can define it from the more primitive notions of direct sum, feedback and hiding: Let

S X Y T Y Z S T X Y Y Z Y fhy yij y Y g

B B

B and . Then , and with , one

S T S T Y j

Z

gets X .

B

S T X X SjT

9. Parallel composition (with interaction). Let B . The parallel composition is defined

SkT to be the agent .

Proposition 6.16. All of the agent constructors in this section respect weak bisimulation. For instance, if

S S T T S S SkT S kT

and , then r and , etc. r

6.3.2 Asynchrony with feedback

In concurrent process calculi such as CCS or the -calculus, we do not think of channels as edges in a data flow graph, but rather we think of a single global ether through which all messages travel. This idea is most visible in the chemical semantics of these calculi [8]. There the ether is modeled as a “chemical solution”, which is a multiset of processes, some of which are transient messages. As a consequence, messages that

are emitted from a process are immediately available as input to all processes, including the sending process

X itself. In our setting, this is best modeled by requiring that all processes are of type X for one fixed set

X , and by using self-composition to feed the output back to the input. In the presence of feedback, out-bufferedness takes a slightly different form, which is expressed in the

following definition.

S X X S R R

Definition. An agent B is out-buffered with feedback if for some out-buffered agent .

Example 6.17. The following agent S is out-buffered with feedback, but not out-buffered: x

out x out

x x x

S in in in

x out x out

Remark. Recently, Amadio, Castellani and Sangiorgi [4] have given a definition of asynchronous bisimula-

X tion, which accounts for the fact that an agent of type X might receive a message, and then immediately send it again, without this interaction being observable on the outside. Feedback is concerned with the dual phenomenon, namely a process that sends a message and then immediately receives it again. Out-bufferedness with feedback is characterized up to weak bisimulation by the first-order axioms that are listed in Table 6.5.

94

Table 6.5: First-order axioms for out-buffered agents with feedback

x x x

out x out out out

s s s

s

s s s

s

x

out x out

t t t

s s s

x where out and

output-commutativity (FB1) output-confluence (FB2)

x x

out out x out

s

s s

s

s s

s s

x x

out in x in

t t s

output-determinacy (FB3) feedback (FB4)

x x

out x out out

s s s

s s s

or

in x

out x

t

s s s

output-tau (FB5)

S X X

Theorem 6.18 (Characterization of out-buffered agents with feedback). An agent B is out-buf-

T T fered with feedback if and only if S for some agent satisfying (FB1)–(FB5). Before we prove this theorem, we need two lemmas. The first one gives a useful consequence of the axioms for out-bufferedness with or without feedback.

Lemma 6.19. Suppose an agent S satisfies either (OB1)–(OB3)or(FB1)–(FB5). Then it satisfies the follow-

ing property, which we call backwards output-determinacy:

s s

x

s s

out x out

t t x

out aoutx

t t s g fhs s ijs s t t s

Proof. The proof is straightforward. The relation R or

s is weak bisimulation that relates s and .

The next lemma establishes a technical property needed in the proof of Theorem 6.18. Recall that an agent

T T

T is -reduced if .

A fhs tij s tg

Lemma 6.20. Assume T is -reduced and satisfies (FB1)–(FB5). Define a subset as

s tiA w X

follows: h iff for all sequences , w

out w out

s s u u

out w

v

t t

Then the following hold:

x

out x out

s t s hs tiA hs t iA t t s 1. Whenever and , then iff .

95

x x

out in

t hs ti A s t x X

2. If s and , then for some .

x w

out w out out

hs ti A s u v t u v t s v

Proof. 1. : Assume and . Then there are and with and .

out w

s s v u v hs t iA

By (FB3), s , hence and . This shows .

w w

out out

u hs t iA s v u v t : Conversely, assume and . We show that there exists with and

v .

x w

out w out out

x w s u t u v u u v

Case 1: . We get and by (FB2), and and by

w x

out x out out

hs t i A u v t v v v

the assumption that , then and also by (FB1). By

v v T v v v v

Lemma 6.19, , hence, since is -reduced, . We can take .

w

out x out

x w xw w x s u s

Case 2: . Let be a permutation of that begins with .By(FB1), , and

xw

out w out

s s hs t iA u v t v t v v by (FB3), . Since , one has and for some , hence and

out w

t v

again by (FB3), . w

out

t hs ti A A w X s u

2. Assume s and . By definition of , there exists with such that there

out w

t v u v w w w x w

exists no v with and . Choose such a of minimal length, and let (note

x w

out w out out

s u t t s t v

cannot be the empty sequence). Then s , , and , and there is no with

x w x x

out x in out out in

v u v u t s s u t

t and .By(FB5), there is a transition . From and

x w

out x in out

t t t t t t T

(FB1), one gets s . By Lemma 6.19, , hence since is -reduced. x

out x in

t

This shows s .

R X X R

Proof of Theorem 6.18: Consider the following auxiliary operation on agents: For B , define

by

x

out x in

s s t t

R R R

t t s s

R R

R R

In general, does not respect weak bisimulation. Notice that if satisfies (OB1) or (IB1), then

R .

S X X R

: Suppose B is out-buffered with feedback. Then there is some satisfying (OB1)Ð(OB3),

R R T R

such that S . It is straightforward to verify that satisfies (FB1)Ð(FB5), and we can take

S

R .

T X X T

: Suppose B satisfies (FB1)Ð(FB5). We will show is out-buffered with feedback. Notice

T

that T also satisfies (FB1)Ð(FB5), hence we can without loss of generality assume that is -reduced.

A fhs tij s tg R X X T

Define a subset as in Lemma 6.20. Let B be the agent obtained from by

s t hs ti A jRj jTj s t

removing all transitions of the form where . More precisely, and R iff

s t hs tiA R

and T ,or and . We claim that satisfies (OB1)Ð(OB3). Indeed, (OB1) and

(OB2) follow from the respective properties of T in the case where . In the case where ,(OB1)

T A

for R follows from (FB1) for and Lemma 6.20(1, ); whereas (OB2) follows from the definition of and

R T

Lemma 6.20(1,). Finally, (OB3) for follows directly from (FB3) for .

T R

We now show that . The two agents have the same states. For transitions, first note that R

T R T

, and hence T , with the latter equality holding because of (FB4). For the converse,

s t hs tiA s t hs ti A R

assume T .If or , then and we are done. Else and , and by

x

out x in

s t T R s t

Lemma 6.20(2), holds in , hence in . This shows R .

R R R T We have shown that T for some satisfying (OB1)Ð(OB3). Hence, is out-buffered with

feedback, which finishes the proof of Theorem 6.18.

6.4 Example: Asynchronous CCS

In this section, we will show that an asynchronous version of Milner’s calculus of communicating systems (CCS) [40, 41] fits into the framework of out-buffered labeled transition systems with feedback.

96

Table 6.6: Transitions rules for asynchronous CCS

(act)

P P Q Q

P P

(synch)

P jQ P jQ

G P

(sum)

P P L L

G G P

(res)

P n L P n L

G P

(sum )

P P

G G P

(rel) f

P P

P f P f

(comp)

def

P jQ P jQ

P P A P

(rec)

Q Q

A P

(comp )

P jQ P jQ

fabcg X fa b c g

Let X be an infinite set of names, and let be a corresponding set of co-

X a a

names, such that X and are disjoint and in one-to-one correspondence via . We also write . Names

X X X X f g

correspond to input-actions, and co-names to output-actions. Let , and let Act L

be the set of actions. We use the letters for actions. We use the letter for sets of names, and we

fa j a Lg f f X X

write L for . We use the letter for relabeling functions, which are functions .Any

f a fa f

relabeling function extends to f Act Act by letting and . PQ Let ABC range over a fixed set of process constants. Asynchronous CCS processes and

guards GH are given by the following grammars:

P a P jP Q n L P f A G

P G H aP

G 0 Notice that the choice operator is restricted to input- and -guarded processes. Output-guarded choice is traditionally disallowed in asynchronous process calculi. This is in accordance with the results of this chapter, since output-guarded choice violates the two asynchronous principles of output-determinacy and

output-confluence. For the -calculus, Nestmann and Pierce [44] have recently shown that input-guarded choice can be encoded from the other constructs; hence they include it in their version of the asynchronous

-calculus, and we include it here for asynchronous CCS as well.

def

P A

Assume a set of defining equations A , one for each process constant . The operational semantics

hS i of asynchronous CCS is given in terms of a labeled transition system S CCS Act , which is defined in Table 6.6. The states are CCS processes. Notice that we have not specified a distinguished initial state;

this is more convenient in this context, and no harm is done. Also notice that there is no rule for 0. This is

P

because the process 0 is inert, i.e. there are no transitions 0 .

P G X

Lemma 6.21. If G for a guard , then , i.e. is not an output action.

P Proof. By induction on the derivation of G .

To fit the labeled transition system SCCS into our framework of labeled transition systems with input and

X X X S

output, we simply identify the set X of names with In , and the set of co-names with Out . Then CCS

X is a labeled transition system of type X . Before we prove that this system is out-buffered with feedback,

97

observe that output-determinacy fails for S CCS:

a

a ja ja

0 0 0

a

aj

0

a aj and 0j 0. The following lemma helps to remedy the situation:

Lemma 6.22. An agent S is out-buffered with feedback if it satisfies (FB1), (FB2), (FB5), (FB4) and the

following property (WEAK-FB3), which we call weak output-determinacy: y

out y out

s s

s s

s s

y y out y out out or

out y

t

s s

S

Proof. First notice that if S satisfies the hypothesis, then so does , hence one can without loss of gener-

ality assume that S is -reduced. Next, one shows backwards output-determinacy as in Lemma 6.19. For a S -reduced process, backwards output-determinacy and (WEAK-FB3) already implies (FB3), and therefore

is out-buffered with feedback by Theorem 6.18.

Theorem 6.23. The labeled transition system SCCS is out-buffered with feedback.

Proof. By Lemma 6.22, it suffices to show that S CCS satisfies the axioms (FB1), (FB2), (WEAK-FB3), (FB5), and (FB4). Each of these is proved in a similar fashion. (FB1), (FB2), (WEAK-FB3) and (FB4) can be proved independently, while (FB5) relies on (FB2) and (WEAK-FB3) as hypotheses. Since this is the most interesting case, we show only the proof of (FB5). Suppose therefore that (FB2) and (WEAK-FB3) have already been

proved. We want to show

b b b

Q Q Q

P P P

or

b

b

R S R R

b

Q We show this by induction on the derivation of P . We distinguish six cases based on the last rule in

that derivation. Remember that this last rule cannot have been (sum)or(sum ) by Lemma 6.21.

P b Q R

(act): 0 and 0. This is impossible, since b0 .

b

P P jP Q Q jP P P R Q

(comp): and , where . Then must have been inferred by one of the

R jR

rules (comp), (comp )or(synch). Therefore, R , and one of the following holds:

b

Q R P R P R P

Case 1: P and . By induction hypothesis on and , either there is

b b

S R R S Q S S jP Q

S with and , in which case we can choose ; or else , and hence

b

R jP R Q jP

Q .

R P R S Q jR

Case 2: P and . Then one can choose .

b

R P R b R S Q S

Case 3: P and . In case , we can use (FB2) to get and , and

b b

S S jR b R Q S S

we let . In case , we can use (WEAK-FB3) to get either and , and we

b

S S jR R Q Q Q jP Q jR R let again ; or else , and hence .

(comp ): This case is symmetric to the previous one.

98

Table 6.7: Transitions rules for the core join calculus

str PjQ PQ

N N

P R R P R R str

m m N

N def in

N N R R m

where dn

join x hy i x hy i y v y v P

N n n N n n

x v j jx v  P

n n

where

b

Q P n L Q Q n L P b L R R n L P R

(res): P and , where and . Then and .By

b

S S R S S S n L

induction hypothesis, we get either Q and for some , and we can let .Or

b b

R Q R

else we get Q , hence .

c

Q b f c R P f Q Q f P R R f P

(rel): P and , where and . Then and . By induction

c

S S R S S S f

hypothesis, we get either Q and for some , and we can let . Or else we get

c b

R Q R

Q , hence .

def b

P A A P P A R P R Q (rec): where and . Since , we must also have , and the claim follows

by induction hypothesis.

6.5 Example: The core join calculus

The join calculus was introduced by Fournet and Gonthier in [17] and further developed in [18]. It is a

concurrent, message passing calculus like the -calculus. However, the reaction rule is simpler and closer to the semantics of a chemical abstract machine. Moreover, the scoping rules of the join calculus are such that locality can be easily modeled. The full join calculus deals with a distributed system of locations, and it contains features that deal with such issues as migration and failure. Here, we will only be concerned with

the core join calculus, which is the fragment of the join calculus that pertains to a single location.

xy x y

Let N be a countable set of names. We use to denote names, and to denote sequences RS

of names. Core join calculus processes PQ and rule are given by the following grammars:

P xhyi P jQ R R P R x v j jx v  P

m n n

def in

xhvi R x v j jx v  P v v

n n n

A process of the form is called a message. In the rule , the names

x x R n

are bound, and they are assumed to be distinct. The names are called the defined names of ,

R R R R

m

denoted dn . Finally, all of the defined names of are bound in the process def

R P

m in . For a more comprehensive treatment, see [17, 18].

The semantics of the core join calculus is given in the style of a chemical abstract machine. A state

N

N is a multiset of rules together with a multiset of processes. is a set of names, such that

N fn . We identify states up to -equivalence, i.e. up to renaming of bound variables. The transitions of this machine follow a simple idea: the processes on the right hand side evolve according to the rules on the

left-hand side. There are two kinds of transitions: structural transitions, denoted , and reactions, denoted

join y

. The transition rules are shown in Table 6.7. The rule is of course only applicable is the length of i

v i str N R R

m

and i are the same, for all . Note that in the rule , the sets and dn must be disjoint;

R R P m this may necessitate renaming some bound variables in def in .

99 Remark. In the original formulation of the join-calculus [17, 18], the structural rules are assumed to be

reversible. We adopt a different convention here. Especially the inverse of rule str causes problems in our

setting, as it allows a state under certain conditions to rename its free names.

fxhyijx

To make make the join calculus into a labeled transition system with input and output, let X

y N g

N be the set of messages. We add input and output transitions:

hyi

in x

in xhyi

N

N fxyg

hyi

out x

out xhyi

N N

Further, we let . With these definitions, the join calculus defines a labeled transition system

X X Sjoin .

Theorem 6.24. The labeled transition system Sjoin defined by the core join calculus is out-buffered with feedback.

6.6 Other characterizations of asynchrony

In Sections 6.2 and 6.3, we have characterized notions of asynchrony by first-order axioms up to weak bisim- ulation. It is possible to remove the words “up to weak bisimulation”, i.e. to characterize asynchrony directly. This happens at the cost of introducing second-order axioms. The shift to second-order seems to be inevitable, since weak bisimulation itself is a second-order notion.

6.6.1 Out-buffered agents Consider the two different output transitions in

out y

s u

t

out y

S

in x

v y

out y out

s x t u u The transition has the implicit effect of disabling the action in . The transition has

out y

no such side effect. Roughly, out-bufferedness is characterized by the fact that every output transition

out y

factors into a silent part and a part without side effects. S

The second-order axioms for out-buffered agents are given in Table 6.8. A state s in an LTS is reachable

n 

s s s S T s S

if there exist transitions from the initial state .If , then for every reachable ,

T s t there is reachable t with .

out y

S X Y

Theorem 6.25. An agent B is out-buffered if and only if there exists a binary relation

y Y SjjSj

j for each , satisfying (OB1*)–(OB5*).

S S T T

Proof. : Suppose is out-buffered. By Theorem 6.10, for some satisfying (OB1)Ð(OB3). For y out y out

out y

t t t jSj s s t jTj s s s t , define iff there exist with . It is easy to verify that satisfies (OB1*)Ð(OB5*).

out y

S

: Suppose satisfies (OB1*)Ð(OB5*). Notice that if a relation satisfies (OB1*)Ð(OB5*), then so does y

out y out

. Hence assume without loss of generality that is invariant under weak bisimulation. For any

y y y

w

 n

out out  out out

w y y y Y s s n t t

n sequence , write if . Note that in the case this

100

Table 6.8: Second-order axioms for out-buffered agents

y y y

out y out out out y

out y out

s s t t

t s t s

s s t t

y y

out out y

out y out

t t s s

t s

s t s

y y where out where out (OB3*) (OB1*) (OB2*)

out y out y

out y

t s t s

out y

t s s t

where s reachable (OB4*) (OB5*)

out w

s t R jSjjS Bj R fhs ht w ii j s t g t

means . Consider the relation defined by and reachable .

R s R hs i R

Clearly, relates initial states: . We show that is a weak bisimulation. Suppose

s R ht w i

s

w y y n

where .

y i n i

Case 1: is out i for some . Take the minimal such . Then

y y

y y y

 i

out i out i n

out  out out

s t

y

out i y

out i

y y

y y

 i

out i out n

out  out

s t y

out i

w y y y y s R ht w i ht w i

i i n

by (OB1*) and (OB3*). With we hence have , and also

X t w i

h . w

out w out

y i s s s t s t

Case 2: out i for all . From and , by repeated application of (OB3*), we get

t t s R ht wi ht w i ht wi X and t for some , hence and .

Now suppose

s R ht w i

ht w i

t w i ht w i

We distinguish three cases for h by Definition 6.2: w

out w out

t t t t w w s s s

Case 1: t , and not output. Then implies by repeated

s R ht wi X

application of (OB2*), i.e. s .

t t w w w y y y i n i

n i Case 2: , and not input. If , then out for some . Let be

the minimal such index. Then

y y

y y y

i i

i n

out  out out out out

s t

out y

out y

y

y

 out i

out 

s

out y

s X s R ht w i by (OB4*) and (OB2*), hence .

101 y

out y in

t w w w wy t t

Case 3: t , and . Then .By(OB5*), since is reachable, there is

y y w

out out w out out

t t s s s t t t t

with . Then and repeated application of (OB2*) give , hence

ht w i X sR .

out y

Remark. Notice that Principle 6.1 can be applied to obtain a unique maximal relation , for every y ,

satisfying (OB1*)Ð(OB4*). Thus, S is out-buffered if this unique relation also satisfies (OB5*). Notice in particular how (OB1*) and (OB2*) resemble the definition of weak bisimulation; one may think of the relation

out y as a weak bisimulation up to a suspended output.

6.6.2 In-buffered agents The second-order axioms for in-buffered agents are given in Table 6.9. This is similar to the axioms for out-buffered agents, but notice that there is no analogue to (OB2*). This reflects the fact that unlike output transitions, input transitions can enable, but not disable other transitions.

in x

S X Y

Theorem 6.26. An agent B is in-buffered if and only if there exists a binary relation for each

X x , satisfying (IB1*)–(IB4*).

Proof. : As in the proof of Theorem 6.25.

in x

S

: Suppose satisfies (IB1*)Ð(IB4*). Again, we can without loss of generality assume that is invariant

x x x

w

 n

in in  in in

t w x x x X s s t

n under weak bisimulation. For any sequence , write if

in w

n t jB Sj jSj R fhhw sitijs t g

. Consider the relation R defined by and reachable .

R hs iRs R

Notice that relates initial states: . To see that is a weak bisimulation, suppose

hw si R t

t

in w

in w

s w x x s t s s s t n

where . From , with (IB3*) and weak bisimulation we get , hence

t hw si hs i hs iRt

for some s . Consequently . Conversely, suppose

hw si R t

hw s i

Again, we distinguish three cases:

s w w x w wx x X

Case 1: s , and not output. Then in and for some .By(IB4*),

x w x in x in in in

in x

t t t t t t s t t t t for some , and by (IB3*), , hence also , and we get , i.e.

in x

w siRt t t X h and .

in w

t s w w s t t Case 2: s , and not input. From by repeated application of (IB1*), we get

in w

t hw s iRt X

and s , i.e. . x

out x in

w w s s w x x x x x i n

n i Case 3: , and .If , then must be for some . Let

such i be minimal and construct

x x

x x x

 i

in i in

i n

in  in in

s t

x in

in x

x x

x x

 i

in i in n

in  in

t s

s w iRt X by (IB1*) and (IB2*). This shows h .

102 Table 6.9: Second-order axioms for in-buffered agents

in x

in x

x

in x in

t s s t s

x x

s t

t

s in in

s s t t

IB

( 3*)

x in x in in x

in x

s t

s

s s s

s t s

x where in where s reachable (IB2*) (IB1*) (IB4*)

Table 6.10: Second-order axioms for out-queued agents

y y y

out y out out out

s s t t

s t s t

y

out y out

t t s s

t s where not output where not output

(OQ1*) (OQ2*) y

out y out

s t s t

out y

out y

y z

t z st s

out z and out

s t s (OQ4*) (OQ3*)

out y

out y

t s t s

where s reachable (OQ5*)

Table 6.11: Second-order axioms for in-queued agents

in x

in x x

in x in

t st s

x x

s

t in in s t

s t s t

IQ

( 3*)

x in x in in x

in x

t s

s

s s s

s s t

where not input where s reachable (IQ2*) (IQ1*) (IQ4*)

103 6.6.3 Out-queued and in-queued agents The second-order axioms for out- and in-queued agents are given in Tables 6.10 and 6.11, respectively. Notice that the only difference to the buffered case are the side conditions.

out y

S X Y

Theorem 6.27. An agent B is out-queued if and only if there are relations satisfying (OQ1*)–

in x

S (OQ5*). is in-queued if and only if there are relations satisfying (IQ1*)–(IQ4*).

104 Bibliography

[1] S. Abramsky. Interaction categories and communicating sequential processes. In A. W. Roscoe, editor, A Classical Mind: Essays in honour of C. A. R. Hoare, pages 1Ð16. Prentice Hall International, 1994. [2] S. Abramsky, S. Gay, and R. Nagarajan. Interaction categories and typed concurrent programming. In Proceedings of the 1994 Marktoberdorf Summer School. Springer, 1994. [3] S. Abramsky and A. Jung. Domain theory. In S. Abramsky, D. M. Gabbay, and T. S. E. Maibaum, editors, Handbook of Logic in Computer Science, volume 3, pages 1Ð168. Clarendon Press, 1994.

[4] R. M. Amadio, I. Castellani, and D. Sangiorgi. On bisimulations for the asynchronous -calculus. In Proc. CONCUR ’96, Springer LNCS 1119, pages 147Ð162, 1996. [5] H. P. Barendregt. The Lambda Calculus, its Syntax and Semantics. North-Holland, 2nd edition, 1984. [6] M. A. Bednarczyk. Categories of asynchronous systems. PhD thesis, University of Sussex, 1988.

[7] G. Berry. Stable models of typed -calculi. In Proceedings of the 5th International Colloquium on Automata, Languages and Programming, Springer LNCS 62, pages 72Ð89, 1978. [8] G. Berry and G. Boudol. The chemical abstract machine. Theoretical Computer Science, 96:217Ð248, 1992.

[9] G. Boudol. Asynchrony and the -calculus. Technical Report 1702, INRIA, Sophia-Antipolis, 1992. [10] K. B. Bruce and A. R. Meyer. The semantics of second-order polymorphic lambda calculus. In G. Kahn, D. B. MacQueen, and G. Plotkin, editors, Proc. Conf. on Semantics of Data Types, Sophia-Antipolis, 1984, Springer LNCS 173, pages 131Ð144, 1984. [11] S. Bulman-Fleming and W. Taylor. Union-indecomposable varieties. Colloquium Mathematicum, 35:189Ð199, 1976. [12] A. Church and J. B. Rosser. Some properties of conversion. Transactions of the American Mathematical Society, 39:472Ð482, 1936.

[13] P. M. Cohn. Universal Algebra, Revised Edition. D. Reidel Publishing, Holland, 1981. [14] D. Cubri«ˇ c. Embedding of a free cartesian closed category into the category of sets. Journal of Pure and Applied Algebra, 1995. [15] D. Cubri«ˇ c. On the semantics of the universal quantifier. Annals of Pure and Applied Logic, 1997. To appear. [16] P. Di Gianantonio, F. Honsell, S. Liani, and G. D. Plotkin. Countable non-determinism and uncountable limits. In Proceedings of CONCUR ’94, Springer LNCS 836, 1994. See also: Uncountable limits and the Lambda Calculus, Nordic Journal of Computing 2, 1995.

105 [17] C. Fournet and G. Gonthier. The reflexive cham and the join-calculus. In POPL ’96: Proceedings of the 23rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 1996.

[18] C. Fournet, G. Gonthier, J.-J. Levy, L. Maranget, and D. Remy. A calculus of mobile agents. In Proceedings of CONCUR ’96, Springer LNCS 1119, pages 406Ð421, 1996. [19] P. J. Freyd. Combinators. In Proc. Mathematical Applications to Computer Science. American Mathe- matical Society, 1989. [20] P. J. Freyd and A. Scedrov. Categories, Allegories. North-Holland, 1989. [21] H. Friedman. Equality between functionals. In R. Parikh, editor, Proceedings of the Logic Collo- quium ’73, Springer Lecture Notes in Mathematics 453, pages 22Ð37, 1975. [22] J.-Y. Girard. Une extension de l’interpretation de G¬odela ` l’analyse, et son application a l’elimination des coupures dans l’analyse et la th«eorie des types. In J. E. Fenstad, editor, Proceedings of the Second Scandinavian Logic Symposium, pages 63Ð92. North-Holland, 1971.

[23] J.-Y. Girard. The system F of variable types, fifteen years later. Theoretical Computer Science, 45:159Ð 192, 1986. [24] G. Gr¬atzer. Universal Algebra. D. Van Nostrand, 1968.

[25] J. Hagemann and A. Mitschke. On n-permutable congruences. Algebra Universalis, 3:8Ð12, 1973. [26] K. Honda and M. Tokoro. An object calculus for asynchronous communication. In Proc. ECOOP 91, Geneve, 1991. [27] F. Honsell and S. Ronchi Della Rocca. An approximation theorem for topological lambda models and the topological incompleteness of lambda calculus. Journal of Computer and System Sciences, 45(1), 1992. [28] G. Huet, editor. Logical Foundations of Functional Programming. Addison-Wesley, 1990. [29] M. Hyland. A syntactic characterization of the equality in some models for the lambda calculus. J. London Math. Soc., 12:361Ð370, 1976. [30] B. Jacobs, I. Margaria, and M. Zacchi. models with polymorphic types. Theoretical Computer Science, 95:143Ð158, 1992. [31] C. P. J. Koymans. Models of the lambda calculus. Information and Control, 52:306Ð332, 1982. [32] J.-L. Krivine. Lambda-calculus, types and models. Masson, 1993.

[33] J. Lambek. From -calculus to cartesian closed categories. In J. P. Seldin and J. R. Hindley, editors, To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pages 375Ð402. Academic Press, London, New York, 1980. [34] J. Lambek and P. J. Scott. An Introduction to Higher Order Categorical Logic. Cambridge Studies in Advanced Mathematics 7. Cambridge University Press, New York, 1986. [35] N. A. Lynch and E. W. Stark. A proof of the Kahn principle for input/output automata. Information and Computation, 82:81Ð92, 1989. [36] S. MacLane. Categories for the Working Mathematician. Springer GTM 5. 1971. [37] A. I. Mal’cev. K obˇsˇceˇõ teorii algebraiˇceskih sistem. Mat. Sb. N. S. 35 (77), pages 3Ð20, 1954. [38] A. R. Meyer. What is a model of the lambda calculus? Information and Control, 52:87Ð122, 1982.

106 [39] A. R. Meyer, J. C. Mitchell, E. Moggi, and R. Statman. Empty types in polymorphic lambda calculus. In Proceedings of the 14th ACM Symposium on Principles of Programming Languages, pages 253Ð262, 1987. Reprinted in [28]. [40] R. Milner. A Calculus of Communicationg Systems. Springer LNCS 92. 1980. [41] R. Milner. Operational and algebraic semantics of concurrent processes. In J. van Leeuwen, editor, Handbook of Theoretical Computer Science, volume B. Elsevier, 1990. [42] J. C. Mitchell and E. Moggi. Kripke-style models for typed lambda calculus. Annals of Pure and Applied Logic, 51:99Ð124, 1991.

[43] J. Myhill and R. Flagg. A type-free system extending (ZFC). Annals of Pure and Applied Logic 43, pages 79Ð97, 1989. [44] U. Nestmann and B. C. Pierce. Decoding choice encodings. In Proceedings of CONCUR ’96, Springer LNCS 1119, pages 179Ð194, 1996.

[45] C. Palamidessi. Comparing the expressive power of the synchronous and the asynchronous -calculus. In POPL ’97: Proceedings of the 24th Annual ACM SIGPLAN-SIGACT Symposium on Principles of

Programming Languages (Paris), 1997. [46] G. D. Plotkin. The -calculus is -incomplete. The Journal of Symbolic Logic, 39:313Ð317, 1974. [47] G. D. Plotkin. Domains. Department of Computer Science, University of Edinburgh, 1983. [48] G. D. Plotkin. Set-theoretical and other models of the lambda-calculus. Theoretical Computer Science, 121:351Ð409, 1993. [49] G. D. Plotkin. A semantics for static type inference. Information and Computation, 109:256Ð299, 1994. [50] G. D. Plotkin. On a question of H. Friedman. Information and Computation, 126(1):74Ð77, 1996. [51] J. C. Reynolds. Towards a theory of type structure. In Proceedings, Colloque sur la Programmation, Springer LNCS 19, pages 408Ð425, 1974. [52] J. C. Reynolds. Polymorphism is not set-theoretic. In International Symposium on Semantics of Data Types, Springer LNCS 173, pages 145Ð156, 1984. [53] D. S. Scott. Continuous lattices, toposes, algebraic geometry and logic. In F. W. Lawvere, editor, Proc. 1971 Dalhousie Conference, Springer Lecture Notes in Mathematics 274, pages 97Ð136, 1972.

[54] D. S. Scott. Relating theories of the -calculus. In To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pages 403Ð450. Academic Press, London, New York, 1980. [55] R. A. G. Seely. Hyperdoctrines, natural deduction and the Beck condition. Zeitschrift fur¨ mathematische Logik und Grundlagen der Mathematik, 29:505Ð542, 1983. [56] R. A. G. Seely. Categorical semantics for higher order polymorphic lambda calculus. The Journal of Symbolic Logic, 52(4), Dec. 1987. [57] P. Selinger. Order-incompleteness and finite lambda models. Extended abstract. In Proceedings of the Eleventh Annual IEEE Symposium on Logic in Computer Science, pages 432Ð439, 1996. [58] P. Selinger. First-order axioms for asynchrony. In Proceedings of CONCUR ’97, Springer LNCS, 1997. To appear. [59] M. W. Shields. Concurrent machines. Theoretical Computer Science, 28:449Ð465, 1985.

107 [60] A. K. Simpson. Categorical completeness results for the simply-typed lambda-calculus. In Proc. TLCA ’95, Springer LNCS 902, pages 414Ð427, 1995.

[61] M. B. Smyth and G. D. Plotkin. The category-theoretic solution of recursive domain equations. SIAM Journal on Computing, 11(4):761Ð783, 1982. [62] C. Strachey. Fundamental concepts in programming languages. Unpublished lecture notes, International Summer School in Computer Programming, Copenhagen, Aug. 1967. [63] W. Taylor. Structures incompatible with varieties, Abstract 74T-A224. Notices of the American Mathe-

matical Society, 21:A-529, 1974. D

[64] C. P. Wadsworth. The relation between computational and denotational properties for Scott’s - models of the lambda-calculus. SIAM Journal on Computing, 5:488Ð521, 1976.

108 Index

absolute interpretation term algebra, 14 in an algebra, 27, 39 algebraic signature, 13 of the lambda calculus, 26 algebraic variety, 14 absolutely unorderable algebra, 39 of combinatory algebras, 22 action, 84 of lambda algebras, 24

in CCS, 97 -diagram, 73

input and output, 85 -equivalence, 20 internal, 85 antisymmetry, 10 silent or unobservable, 84 applicative structure, 22 adjunction, 7 extensional, 30 agent, 85 order-extensional, 49

buffer B ,87 ordered, 47 buffered, 87 partial, 51 composition with function, 93 unorderable, 36 domain extension and restriction, 93 arity, 13 feedback, 94 asynchronous CCS, 96 hiding, 93 asynchrony, 83, 87 in-buffered, 87 in-queued, 87 backwards output-determinacy, 95 input and output action, 85 base category, 72 internal action, 85 Beck-Chevalley condition, 73 isomorphism of, 86 Berry order, 11

operations on, 93 -conversion, 20

out-buffered, 87 -reduction, 21 out-buffered with feedback, 94 bilimit, 12 out-queued, 87 binary product, 8 output action, 85 bisimulation parallel composition strong, 84 with interaction, 94 weak, 84 without interaction, 93 bound name, in join calculus, 99

queue Q,87 bound variable, in lambda calculus, 20, 64, 78 queued, 87 bound, upper and lower, 10 renaming, 93 bounded complete cpo, 11 self-composition, 94 bounded tree, 50

sequential composition, 85 buffer B ,87 silent action, 84 buffered agent, 87 symmetric monoidal structure, 93 algebra, 13 calculus of communicating systems, 96 dcpo-algebra, 17, 41 cartesian-closed category, see ccc free, 14 categorical model ordered, 16, 40 of conversion, 30 polynomial, 15 of reduction, 48 quotient, 13 categories

109 equivalence of, 7 communication category, 5 asynchronous, 83, 87 cartesian-closed, see ccc synchronous, 83 cocomplete, 8 commutativity complete, 8 input, 90 discrete, 5 output, 89 dominated by a poset, 64 compatible elements, 10, 38, 50 dual, 5 compatible relation, 13 functor category, 7 preorder, 36, 39 of complete partial orders CPO,11 complete category, 8 of directed complete partial orders DCPO, complete lattice, 10

11 complete partial order, 11

of non-empty sets S ,62 bounded complete, 11

op C

of presheaves S ,9 meet cpo, 11 P

of presheaves over a poset S ,63 composition, 5

of sets S ,5,62 agent and function, 93 PL-category, 72 parallel

small, 5 with interaction, 94 e

standard structure D ,75 without interaction, 93 ccc, 9 sequential, 85, 94 associated to a theory, 67 cone, 7 congruence, 58 collectively monic, 6 free, 67 limiting, 8 representation, 9 confluence Henkin representation, 58 Church-Rosser, 21 special, 62, 70 input, 90 CCS, 96 output, 89 chain, 11 congruence channel on algebra, 13 asynchronous, 83, 87 on ccc, 58 synchronous, 83 on PL-category, 74 Church numerals, 21 consistency Church-Rosser property, 21 of the lambda calculus, 22 closed combinatory term, 22 of the Mal’cev axioms, 42 closed lambda term, 20 constant, 20 closed term algebra, 22, 36 individual, 64, 78 co-name, in CCS, 97 process, 97 co-unit of adjunction, 7 type, 64 cocomplete category, 8 continuity

cocone, 8 -continuity, 11 codomain of a morphism, 5 Scott-continuity, 11 colimit, 8 continuous functor, 12 collectively monic, 6 locally, 13 combinator, 22 continuously complete model, 38 combinatory algebra, 22 contravariant functor, 6 homomorphism of, 22 conversion, 20 unorderable, 36 categorical model of, 30 valuation in, 22 syntactical model of, 48 combinatory completeness, 23 core join calculus, 99 combinatory logic, 22 core of an extended theory, 70 derived lambda abstractor, 23 covariant functor, 6 combinatory term, 22 cover, 60

110 split, 60 epic, 6 cpo, 11 split, 6 bounded complete, 11 epimorphism, 6 meet cpo, 11 equalizer, 8 Curry algebra, 30 equation Curry axioms for lambda algebras, 24 defining CCS process, 97 currying, 9 extended, 70

in algebra, 14 D -model, 13, 54 inequation, 16 dcpo, 11 of polymorphic lambda calculus, 78 dcpo-algebra, 17, 41 of simply-typed lambda calculus, 65 dcpo-variety, 17, 41 equivalence of categories, 7

defined name, in join calculus, 99 -conversion, 20

derived lambda abstractor, 23 -reduction, 21 determinacy expanding sequence, 12 input, 90 exponential diagram, 9 output, 89 extended equation, 70 backwards, 95 extended theory, 70 weak, 98 core of, 70 diagonal axiom, 42 principal, 70 diagram, 7 extensionality, 30

-diagram, 73 order, 49 binary product, 8 strong, 50 exponential, 9 weak, 29 limit of, 8

partial -diagram, 74 faithful functor, 7 partial exponential, 59 faithful subcategory, 7 product, 8 feedback, 94 diamond property, 21 fiber, 72 directed complete partial order, 11 finitely separable lambda algebra, 36 directed equality, 51 flat poset, 10 directed poset, 11 free discrete category, 5 algebra, 14 discrete preorder, 36 ccc, 67 domain, 12 dcpo-algebra, 17 domain equations, 12 ordered algebra, 16, 40 domain extension and restriction, 93 variable, 20, 64, 78 domain of a morphism, 5 full functor, 7 dominated category, 64 full subcategory, 7 downdeal, 10 function downward closed set, 10 continuous, 11 dual category, 5 monotone, 10 dummy functor, 73, 74 stable, 11 function symbol, 13 embedding functor, 6 Henkin, 62Ð71 adjoint, 7 Henkin-PL,75 ccc-representation, 9 of categories, 7 continuous, 12 Yoneda, 9 contravariant, 6 embedding-projection pair, 12 covariant, 6 emptiness assertion, 69 embedding, 7 empty types, 68, 69, 82 faithful, 7

111 full, 7 input-determinacy, 90 Henkin representation, 58 input-receptivity, 90 Henkin-PL-representation, 74 internal actions, 85 inclusion, 7 interpretation kernel, 58 in ccc, 65 left-full, 63 non-strict, 67 locally continuous, 13 in PL-category, 79 PL-representation, 73 non-strict, 81 representable, 7 inverse, 6 Yoneda, 9 iso, 6 functor category, 7 isomorphism, 6 natural, 7 generalized Mal’cev operators, 40 of labeled transition systems, 86 greatest lower bound, 10 guard in CCS, 97 , 10 join calculus, 99 height of a bounded tree, 50 Henkin natural transformation, 74 kernel Henkin representation, 58 of a functor, 58

in S ,62 of a Henkin representation, 58 P

in S ,63 of a Henkin-PL-representation, 74

in S ,62 of a homomorphism, 13 Henkin-PL-embedding, 75 of a PL-representation, 74

Henkin-PL-representation, 74 Kleene equality, 52

g P

in S ,77 Kripke lambda model

g

in S ,77 polymorphic, 82 hiding, 93 simply-typed, 72 hom-set, 5 homomorphism, 13 labeled transition system, 84 with input and output, see agent ideal completion, 41 lambda algebra, 24 ideal in a poset, 41 and reflexive ccc models, 31 identity morphism, 5 finitely separable, 36 in-buffered agent, 87 homomorphism of, 24 first-order axioms for, 90 soundness and completeness, 28

second-order axioms for, 103 soundness of ( )-rule, 27 in-queued agent, 87 lambda calculus first-order axioms for, 90 absolute interpretation, 26 second-order axioms for, 103 closed term algebra, 22 inclusion functor, 7 consistency, 22 indeterminate, 15 conversion, 20 indiscrete preorder, 36 local interpretation, 24 individual constant, 64, 78 model, see model individual variable, 78 open term algebra, 22 inequation, 16 polymorphic, 78 infimum, 10 reduction, 21 initial state of labeled transition system, 84 simply-typed, 64 input actions, 85 untyped, 20 input and output lambda conversion, 20 labeled transition system with, see agent categorical model of, 30 input-commutativity, 90 syntactical model of, 48 input-confluence, 90 lambda model, 29

112 lambda reduction, 21 of lambda conversion lambda term categorical, 30 boolean, 21 syntactical, 48 Church numeral, 21 of lambda reduction closed, 20 categorical, 48 normal form of, 21 syntactical, 48 raw, 20, 64, 78 of polymorphic lambda calculus, 79, 81 substitution of, 20 of simply-typed lambda calculus, 65, 67 untyped, 20 partial, 51 lambda theories reflexive ccc model, 30 category of, 28 set-theoretic, 68, 82 lambda theory, 20 standard models of polymorphism, 82

,20 strict, 65, 79

,20 topological, 38 pure, 20, 65 tree model, 50 lambda-order, 43 with empty types, 68, 69, 82 lambda-preorder, 43 with non-empty types, 69, 82 lattice, 10 monic, 6 complete, 10 collective, 6 least upper bound, 10 cone, 6 left-full functor, 63 split, 6 lift of a model of reduction, 54 monomorphism, 6 limit, 8 monotone function, 10 limit-colimit coincidence, 12 morphism, 5 limiting cone, 8 colimiting, 8 limiting morphism, 8 cover, 60 linear order, 11 currying, 9 local interpretation epic, 6

failure of rule ( ), 25 identity, 5 of combinatory logic, 23 inverse, 6 of the lambda calculus, 24 iso, 6 locally continuous functor, 13 limiting, 8 locally well-pointed object, 32 monic, 6 lower bound, 10 pairing, 9 LTS, see labeled transition system projection, 8 uncurrying, 9 Mal’cev axioms, 40

Mal’cev operator, 40 n-permutability, 40 Mal’cev variety, 40 name map, see function defined, 99 maximum and minimum, 10 free and bound, 99 meet and join, 10 in CCS, 97 meet cpo, 11 in join calculus, 99 message, in join calculus, 99 natural isomorphism, 7 Meyer-Scott axiom, 29 natural transformation, 7 minimum and maximum, 10 Henkin, 74 model (non-empty) rule, 68

continuously complete, 38 non-empty types, 69, 82 D

,13 non-strict interpretation finitely separable, 36 of polymorphic lambda calculus, 81 Kripke, 72, 82 of simply-typed lambda calculus, 67 non-strict, 67, 81 normal form, 21

113 object in category, 5 base, 72

-chain, 11 congruence, 74

-complete poset, see cpo fiber, 72

-continuity, 11 representation of, 73 open term algebra, 22, 36 Henkin-PL-representation, 74 operation in algebra, 14 pointed poset, 10 order, 10 pointwise order, 10 Berry, 11 polymorphic Kripke model, 82 complete, see cpo polymorphic lambda calculus, 78 directed, 11 polymorphic signature, 78 directed complete, 11 polynomial, 15 linear, 11 polynomial algebra, 15

-complete, see cpo poset, see order partial, 10 directed, 11 pointwise, 10 directed complete, 11 preorder, 10 flat, 10 stable, 11 linearly ordered, 11

order-extensionality, 49 -complete, see cpo ordered algebra, 16, 40 pointed, 10 ordered applicative structure, 47 pre-structure, 74 order-extensional, 49 preorder, 10 strongly extensional, 50 discrete, 36 ordered variety, 16, 40 indiscrete, 36 out-buffered agent, 87 symmetric, 36 first-order axioms for, 89 trivial, 36 second-order axioms for, 101 presheaf, 9, 63 with feedback, 94 principal extended theory, 70 first-order axioms for, 95 process out-queued agent, 87 in CCS, 97 first-order axioms for, 90 in join calculus, 99 second-order axioms for, 103 process constant in CCS, 97 output actions, 85 product, 8 output-commutativity, 89 binary, 8 output-confluence, 89 of categories, 5 output-determinacy, 89 projection morphism, 8 backwards, 95 projection-embedding pair, 12 weak, 98 pullback, 8 pure lambda theory, 20 pairing, 9 polymorphic, 79 parallel composition simply-typed, 65 with interaction, 94

without interaction, 93 queue Q,87

partial -diagram, 74 queued agent, 87 partial applicative structure, 51 quotient algebra, 13 partial exponential diagram, 59 partial initial object, 60 raw lambda term, 20 partial model, 51 polymorphic, 78 partial order, see order simply-typed, 64 complete, see cpo reachable state, 100 directed complete, 11 reaction in join calculus, 99 partial syntactical lambda model, 51 receptivity, 90 PL-category, 72 redex, 21

114 -reduced agent, 84 state

-reduced agent, 84, 95 in join calculus, 99 reduction, 21 initial, 84 categorical model of, 48 of labeled transition system, 84 syntactical model of, 48 reachable, 100 reflexive ccc model, 30, 37 strict interpretation and lambda algebras, 31 of polymorphic lambda calculus, 79 reflexive object, 30 of simply-typed lambda calculus, 65 reflexivity, 10 strong bisimulation, 84 relabeling function in CCS, 97 strong extensionality, 50 relation structural transition in join calculus, 99 compatible, 13 subalgebra, 13 congruence, 13 subcategory, 7 representable functor, 7 faithful, 7 representation full, 7 Henkin-PL,74 substitution, 20 of ccc’s, 9 supremum, 10 of PL-categories, 73 symmetric preorder, 36 rule (non-empty), 68 synchrony, 83 rule, in join calculus, 99 syntactical model of conversion, 48 Scott-continuity, 11 of reduction, 48 self-composition of agent, 94

separable subset of lambda algebra, 36 T-algebra, 14 sequence, expanding, 12 target of a morphism, 5 sequential composition, 85, 94 term set-theoretic model combinatory, 22 of polymorphism, 82 lambda, 20

of simply-typed lambda calculus, 68 -term, 14 with empty types, 68, 69, 82 term algebra, 14 with non-empty types, 69, 82 open and closed, 22, 36

-algebra, 13 terminal object, 8

-term, 14 terminator, 8 signature theory algebraic, 13 extended, 70 polymorphic, 78 of combinatory logic, 22 simply-typed, 64 polymorphic, 79 silent action, 84 simply-typed, 65 simple type, 64 untyped, 20 simply-typed lambda calculus, 64 topological completeness problem, 38 simply-typed signature, 64 topological model, 38 small category, 5 transition relation, 84 source of a morphism, 5 in join calculus, 99 special ccc, 62, 70 transition system, see labeled transition system split cover, 60 transitivity, 10 split epic, 6 translation of lambda theories, 28 split monic, 6 tree, 50 stable function, 11 bounded, 50 stable order, 11 tree model, 50 standard model, 82 trivial preorder, 36 standard structure, 75 type standard term algebra, 22, 36 constant, 64, 78

115 of a labeled transition system, 84 polymorphic, 78 simple, 64 variable, 78 type assignment polymorphic, 78 simply-typed, 65 typed lambda calculus, 64, 78 typing judgment polymorphic, 78 simply-typed, 65

un--orderable, 43

un--preorderable, 43 un-preorderable, 43 uncurrying, 9 unit of adjunction, 7 unobservable action, 84 unorderable absolutely, 39 combinatory algebra, 36, 43

T-algebra, 39 untyped lambda calculus, 20 updeal, 10 upper bound, 10 valid typing judgment polymorphic, 78 simply-typed, 65 valuation in algebra, 14 in applicative structure, 22 in ordered applicative structure, 47 variable, 14, 20, 64 free and bound, 20, 64, 78 individual, 78 type, 78 variety algebraic, 14 dcpo, 17, 41 ordered, 16, 40 weak bisimulation, 84 weak extensionality, 29 weak output-determinacy, 98 well-pointed object, 32, 59 locally, 32 well-supported object, 60

Yoneda embedding, 9

0-fiber, 73

116