A Mathematical Investigation of Programming Paradigms
Total Page:16
File Type:pdf, Size:1020Kb
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, Dana Scott, 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 category 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 domain theory . ..................................... 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