The Lazy Lambda Calculus: An Investigation into the Foundations of Functional Programming C.-H. Luke Ong Submitted for the degree of Doctor of Philosophy Imperial College of Science and Technology University of London May 31, 1988 2 Abstract The commonly accepted basis for functional programming is the A-calculus; and it is folklore that A-calculus is the prototypical functional language in puri­ fied form. There is, nonetheless, a fundamental mismatch between theory and practice: • Much of what is known about the model theory and proof theory of the A-calculus is sen sib le in nature, i.e. all unsolvables are identified. Crucially, Ax._L = _L where _L represents any divergent term (or program). • In practice, however, most implementations of functional languages are la z y , i.e. programs are reduced in normal order to weak head normal forms (whnf), corresponding to a call-by-name semantics. Consequently, Ax._L ^ _L, because all abstractions, being in whnf, are deemed to be legitimate and meaningful programs. This thesis seeks to develop a theory of la z y functional programming that corresponds to practice in the framework of the classical A-calculus. The main topics studied in this thesis are as follows: • The fundamental notions of solvability, A-definability (of numeric func­ tions) , A-theories and tree semantics in the classical sensible A-calculus are reviewed and revised in the light of the lazy regime. • Different formulations of lazy X-models are presented and shown equivalent. We prove a Local Structure Theorem for the class of free lazy PSE-models. • The full abstraction problem recast in the lazy A-calculus, a la Abram- sky, is studied. We focus on the lazy X-calculus with convergence testing and study the problem of call-by-value simulation. A general method for constructing fully abstract models which are retracts of D — the initial solution of the domain equation D = [D —> D]± — with respect to a class of sufficiently expressive variants of Abramsky’s A t is developed. The full abstraction problem of A t is reduced by this method to an open question of the conservativity of a labelled version of A i over itself. • A proof system for the lazy A-calculus (with convergence testing) based on Scott’s logic of existence which is co rre ct with respect to A is introduced and given a s o u n d and com plete interpretation in partial categories. L a z y reflexive objects with enough points in partial Cartesian closed dominical cate g orie s give rise to lazy A-models in which convergence testing is defin­ able, thereby yielding a partial categories semantics. 2 3 Acknowledgements I am immensely indebted to my two supervisors, Dr. Samson Abramsky and Professor John Darlington, for giving me freedom to pursue my own research interests and their careful efforts as academic mentors to help me cultivate confi­ dence in my work. This thesis would scarcely have been written without Samson Abramsky who suggested the research topic to me in April 1986, and provided directions, even specific problems, at various crucial points in the course of my PhD programme. I would like to pay a special tribute to, what I term, his peda­ gogical perspicacity. For one thing, the past two years of comparatively smooth and thoroughly joyful course of research owes much to his judicious suggestion of Lazy Lambda Calculus as my research topic. His choice, and particularly, the timing — clearly in evidence of his acute discernment of my interests and masterly appreciation of what (little) I knew and was capable of learning as a somewhat perfervid and clumsy first year PhD student — set me off to a re­ search area which he had evidently perceived to be fecund. For another thing, throughout our regular meetings over the past two and a half years, his insightful supervision and unflagging enthusiasm in my work were the most valuable help to me. His approach to Computer Science — always with rigour, much elegance, refreshingly cultured and philosophically informed, and finesse as a lecturer and teacher shall remain as a lasting influence on me. I owe a special debt to Eugenio Moggi whom I first met at the British The­ oretical Computer Science Colloquium at Leeds in March 1986. It was his talk at the Colloquium that fired my enthusiasm in Lambda Calculus. Since then, he has remained the most helpful of collaborators and generous of friends. Those who are familiar with his work on Lambda Calculus and Partial Categories will surely notice the significance of its influence on the work reported in Chapter 5 of this thesis. I am very grateful to my colleagues from both the Functional Programming Research Group and the Computing Theory and Systems Technology Group in the Department of Computing for making scarce resources available for my use and also for providing a most lively and conducive environment for research. A special word of thanks goes to Axel Poigne (who left Imperial College in late 1987 to join GMD, West Germany) for his interest in my work and constant encour­ agement; and to Tom Maibaum for making special provisions to accommodate me in room 206A (for nearly a year) whose relative spaciousness and proximity to the Sun workstations I very much appreciate. I thank also Colin Atkinson, Mark Dawson, Yves Lafont and Paul Taylor who share the office with me for making it an enjoyable place in which to work. In particular, Mark’s expertise in the nitty-gritties of systems programming and Paul’s convenient package of 3 4 macros for generating category-theoretic diagrams have made the task of document preparation using I^TjjX so much less painful. Various colleagues outside of London have contributed much to my research programme. For a start, I ought to thank Alan Mycroft, Arthur Norman and Glynn Winskel from the Computer Laboratory in Cambridge for initiating me into Computer Science. I must especially acknowledge the advice given by Glynn Winskel in August 1985 (which I subsequently took up) regarding the institu­ tion in which to do my PhD and possible supervisors. I thank him for his ad­ vice, encouragement and interest in my work even after I have left Cambridge. Discussions with Henk Barendregt, Thierry Coquand, Carl Gunter, Furio Hon- sell, Giuseppe Longo, Mogens Nielson, Gordon Plotkin, Pino Rosolini and Allen Stoughton have helped me develop my ideas and improved the presentation of my work. In particular, it is with great pleasure and appreciation that I acknowledge the influence and inspiration of the work of Gordon Plotkin, Giuseppe Longo and Henk Barendregt. The problems they posed and techniques pioneered are central to my thesis. This thesis would definitely not have been written without the financial aids arranged by Prof. Darlington: first, in the form of an Imperial College Bursary, and then research assistantship on the Alvey Project Flagship. I am deeply indebted to his commitment to academic freedom; his tolerance of and kindness to this independently spirited student has often been a striking surprise to me. It is my sincere hope that the fruit of my research will contribute somewhat to the theory of functional programming. I am grateful to my parents and my friends at the SWDCG for their support and love which means a great deal to me. Last, but not least, I thank Soo May for enriching the last year of my re­ search beyond measure. I appreciate especially her sympathetic understanding throughout the time of my thesis preparation and patience in bearing the frus­ trating “nebulousness” of my companionship — for when I was writing I was not really with her even if I was; and when I was not writing, I was helplessly stricken with gloom for not doing what I had set out to do. 4 C on ten ts 1 Introduction 8 1.1 P r e a m b le ......................................................................................................... 8 1.1.1 Lazy Evaluation .............................................................................. 9 1.1.2 The Lambda Calculus: An Introduction and Some Nota­ tions ...................................................................................................... 11 1.2 Mismatch between Theory and P ractice ................................................. 14 1.2.1 Solvability: Meaningfulness in the Strict R e g im e ......................14 1.2.2 Meaningfulness in the Lazy Regime ..............................................18 1.3 Overview of the Th e s is .................................................................................... 19 2 Sensible Theory Revised: Tree Semantics and Lazy Lambda The­ ories 22 2.1 Laziness and its Properties ............................................................................22 2.1.1 Form ulation of L a z in e s s ..................................................................... 22 2.1.2 Operational Characterization of Strong Unsolvability .... 26 2.1.3 Partial Recursive Functions and A-De {inability Revisited . 30 2.2 Tree S e m a n tic s ....................................................................................................35 2.2.1 Bohm Trees as Operational Semantics .......................................... 35 2.2.2 Weak Bohm T rees ............................................................................... 37 2.2.3 Levy-Longo Trees ............................................................................... 38 2.3 Some Properties of T rees...................................................................................44 2.3.1 Longo Tree Preorder is a P reco n g ru en ce.......................................44
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages256 Page
-
File Size-