ebook img

Lambda-calculus, Combinators and Functional Programming PDF

194 Pages·1988·6.634 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Lambda-calculus, Combinators and Functional Programming

Lambda-Calculus, Combinators, and Functional Programming Cambridge Tracts in Theoretical Computer Science Managing Editor: Professor C. J. van Rijsbergen, Computing Science Department, University of Glasgow, Glasgow, Scotland Editorial Board: S. Abramsky, Department of Computing Science, Imperial College of Science and Technology, London P. H. Aczel, Department of Computer Science, Manchester J. W. de Bakker, Centrum voor Wiskunde en Informatica, Amsterdam J. A. Goguen, Computing Laboratory, University of Oxford J. V. Tucker, Department of Computer Science, University of Swansea Titles in the Series I. G. J. Chaitin Algorithmic Information Theory 2. L. C. Paulson Logic and Computation 3. J. M. Spivey Understanding Z 4. G. E. Revesz Lambda Calculus, Combinators and Functional Programming 5. S. Vickers Topology via Logic 6. A. M. Ramsay Formal Methods in Artificial Intelligence 7. J. Y. Girard Proofs and Types LAMBDA-CALCULUS, COMBINATORS, AND FUNCTIONAL PROGRAMMING G. E. REVESZ IBM Thomas J. Watson Research Center, Yorktown Heights, New York The right of the University of Cambr~dgr ro prmt and srlf ofl manner of hoo/..s wos gromed by Henry VIII m /JJ.f. The Uni~·ersity has pmffed and published rominuously since 1584. CAMBRIDGE UNIVERSITY PRESS Cambridge New York Port Chester JVfelbourne Sydney Published by the Press Syndicate of the University of Cambridge The Pitt Building, Trumpington Street, Cambridge CB2 I RP 40 West 20th Street, New York, NY 10011, USA 10 Stamford Road, Oakleigh, Melbourne 3166, Australia © Cambridge University Press 1988 First published 1988 Reprinted 1989 Printed in Great Britain by Billings & Sons Limited, Worcester British Library cataloguing in publication data Revesz, Gyorgy E. Lambda-calculus, combinators and functional programming.-(Cambridge tracts in theoretical computer science; v. 4). I. Lambda calculus I. Title 511.3 QA9.5 ISBN 0 521 34589 8 CONTENTS Preface Vll 1. Introduction 1.1 Variables and functions in mathematics and in programming languages 1.2 Domains, types, and higher-order functions 6 1.3 Polymorphic functions and Currying 10 2. Type-free lambda-calculus 2.1 Syntactic and semantic considerations 14 2.2 Renaming, a-congruence, and substitution 18 2.3 Beta-reduction and equality 23 2.4 The Church-Rosser theorem 25 2.5 Beta-reduction revisited 28 3. Combinators and constant symbols 3.1 Lambda-expressions without free variables 35 3.2 Arithmetic and other constants and combinators 39 3.3 Recursive definitions and theY combinator 43 3.4 Elimination of bound variables: bracket abstraction 49 4. List manipulation in lambda-calculus 4.1 An extension of the syntax of .\-expressions 59 4.2 Additional axioms for list manipulation 63 4.3 List manipulating functions 66 vi CONTENTS 4.4 Dealing with mutual recursion 72 4.5 Computing with infinite lists 76 5. Rule-based semantics of .\-expressions 5.1 Program transformation as a computation 84 5.2 Controlled reduction 89 5.3 The functional programming system FP 94 5.4 Translation of functional programs to .\-calculus 99 5.5 List comprehension in Miranda 103 6. Outlines of a reduction machine 6.1 Graph representation of .\-expressions 113 6.2 The instructions of a reduction machine 118 6.3 Implementation of primitive functions 124 6.4 Demand-driven evaluation 128 7. Towards a parallel graph-reduction 7.1 Harnessing the implicit parallelism 135 7.2 On-the-fly garbage collection 138 7.3 Control of parallelism 147 Appendix A A proof of the Church-Rosser theorem 152 Appendix B Introduction to typed .\-calculus 162 Bibliographical notes 171 References 176 PREFACE There is a growing interest in lambda-calculus and combinators among computer scientists. The appeal of these abstract mathematical theories is due to their elementary yet quite universal nature. They seem to have suc cessfully captured the most general formal properties of the notion of a mathematical function, which, in turn, is one of the most powerful con cepts of modern mathematics. The relevance of lambda-calculus to computer science is quite obvious in many cases. For instance, the design of the programming language LISP has been largely influenced by lambda-calculus. Also, the call by name mechanism of parameter correspondence used in ALGOL-like languages is closely related to the operation of formal substitution as defined pre cisely in lambda-calculus. The same is true for the textual substitution performed by macro generators. More recently John Backus and other proponents of functional style programming have strongly emphasized the importance of the function concept in computer science. Corresponding research efforts to develop efficient implementation techniques for func tional languages have produced many interesting results in the theory of combinators as well as in lambda-calculus. An explicit and systematic use of lambda-calculus in computer science was initiated by Peter Landin, Christopher Strachey, and a few others who started the development of a formal theory of semantics for programming languages based directly on lambda-calculus. Their approach is now called denotationa/ semantics and it is widely accepted as a relevant theory. At first, however, denotational semantics was thought to be flawed by some Vlll PREFACE experts, because of its naive use of the type-free lambda-calculus, which did not seem to have any consistent mathematical model at that time. The first mathematical model for the type-free lambda-calculus was discovered by Dana Scott only in 1969 when he was trying to prove the nonexistence of such models. Since then, lambda-calculus and the theory of combinators have experienced a vigorous revival, which must have surprised even their originators, Alonso Church and Haske! B. Curry, who started their devel opment in the early 30s. Lambda-calculus may also play a more significant role in the theory of parallel algorithms in the future. It represents an abstract mathematical model of computation which is equivalent to the Turing machine. But, while the Turing machine is basically a sequential device, lambda-calculus can retain the implicit parallelism that is normally present in a mathematical expression. In pure mathematics, there is no such thing as the 'side effect' of a computation and thus, independent subexpressions may be computed in parallel. We can take advantage of this type of parallelism when using lambda-calculus. This book approaches lambda-calculus and the theory of combinators from a computer scientist's point of view. It presents only their funda mental facts and some of their applications to functional programming in a self-contained manner. But, in contrast with the usual treatment of lambda-calculus in computer science texts, we present formal proofs for most of the results which are relevant to our discussion. At the same time, lambda-calculus is treated here as a functional language implemented by software on a conventional computer. It can also be implemented by hard ware in a nonconventional computer whose machine code language would be lambda-calculus by itself. As a matter of fact, there already exist ex perimental machines whose instruction sets are fashioned after lambda calculus and/ or combinators. As functional programming is coming of age, several more new hard ware designs aimed at a direct execution of functional programs are likely to appear in the future. Some variant of lambda-calculus will certainly be used in most of them. Future generations of computers will probably have the speed and the necessary sophistication built in the hardware that may make them capable of running functional programs more efficiently, with out placing the burden of controlling the parallelism on the programmer's shoulders.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.