WORKSHOPS IN COMPUTING Series edited by C. J. van Rijsbergen Also in this series Z User Workshop, York 1991, Proceedings of the Formal Methods In Databases and Software Sixth Annual Z User Meeting, York, Engineering, Proceedings of the Workshop on 1~17 December 1991 Formal Methods in Databases and Software J.E. Nicholls (Ed.) Engineering, Montreal, Canada, 15-16 May 1992 V.S. Alagar, Laks V.S. Lakshmanan and Formal Aspects of Measurement F. Sadri (Eds.) Proceedings of the BCS-FACS Workshop on Formal Aspects of Measurement, South Bank Modelling Database Dynamics University, London, 5 May 1991 Selected Papers from the Fourth International Tim Denvir, Ros Herman and R.W. Whitty (Eds.) Workshop on Foundations of Models and Languages for Data and Objects, Volkse, Germany, AI and Cognitive Science '91 19-22 October 1992 University College, Cork, 19-20 September 1991 Udo W. Lipeck and Bernhard Thalheim (Eds.) Humphrey Sorensen (Ed.) 14th Information Retrieval Colloquium 5th Refinement Workshop, Proceedings of the 5th Proceedings of the BCS 14th Information Refinement Workshop, organised by BCS-FACS, Retrieval Colloquium, University of Lancaster, London, 8-10 January 1992 13-14 April 1992 aiff B. Jones, Roger C. Shaw and Tony McEnery and Chris Paice (Eds.) Tim Denvir (Eds.) Functional Programming, Glasgow 1992 Algebraic Methodology and Software Proceedings of the 1992 Glasgow Workshop on Technology (AMAST'91) Functional Programming, Ayr, Scotland, Proceedings of the Second International Conference ~8 July 1992 on Algebraic Methodology and Software John Launchbury and Patrick Sansom (Eds.) Technology, Iowa City, USA, 22-25 May 1991 M. Nivat, C. Ranray, T. Rus and G. Scollo (Eds.) Z User Workshop, London 1992 Proceedings of the Seventh Annual Z User ALPUK92, Proceedings of the 4th UK Meeting, London, 14-15 December 1992 Conference on Logic Programming, J.P. Bowen and J.E. Nicholls (Eds.) London, 30 March -1 April 1992 Krysia Broda (Ed.) Interfaces to Database Systems (IDS92) Proceedings of the First International Workshop Logic Program Synthesis and Transformation on Interfaces to Database Systems, Proceedings of LOPS1R 92, International Glasgow, 1-3 July 1992 Workshop on Logic Program Synthesis and Richard Cooper (Ed.) Transformation, University of Manchester, 2-3 July 1992 AI and Cognitive Science '92 Kung-Kiu Lau and Tim aement (Eds.) University of Limerick, 10-11 September 1992 Kevin Ryan and Richard F.E. Sutcliffe (Eds.) NAPA W 92, Proceedings of the First North American Process Algebra Workshop, Stony Brook, Theory and Formal Methods 1993 New York, USA, 28 August 1992 Proceedings of the First Imperial College S. Purushotharnan and Amy Zwarico (Eds.) Department of Computing Workshop on Theory and Formal Methods, Isle of Thoms Conference Arst International Workshop on Larch Centre, Chelwood Gate, Sussex, UK, Proceedings of the First International Workshop on 29-31 March 1993 Larch, Dedham, Massachusetts, USA, Geoffrey Bum, Simon Gay and Mark Ryan (Eds.) 13-15 Julyl992 Ursula Martin and Jeannette M. Wing (Eds.) Algebraic Methodology and Software Technology (AMAST'93) Persistent Object Systems Proceedings of the Third International Conference Proceedings of the Fifth International Workshop on on Algebraic Methodology and Software Persistent Object Systems, San Miniato (Pisa), Technology, University of Twente, Enschede, Italy, 1-4 September 1992 The Netherlands, 21-25 June 1993 Antonio Albano and Ron Morrison (Eds.) M. Nivat, C. Rattray, T. Rus and G. Scollo (Eds.) continued on back page ... Yves Deville (Ed.) Logic Program Synthesis and Transformation Proceedings of LOPSTR 93, International Workshop on Logic Program Synthesis and Transformation, Louvain-Ia-Neuve, Belgium, 7-9 July 1993 Published in collaboration with the British Computer Society Springer-Verlag London Berlin Heidelberg New York Paris Tokyo Hong Kong Barcelona Budapest Yves Deville Unite d'Informatique Universite Catholique de Louvain Place Sainte-Barbe 2 B-1348 Louvain-Ia-Neuve, Belgium ISBN-13:978-3-540-19864-2 e-ISBN-13:978-1-4471-3234-9 DOl: 10.1007/978-1-4471-3234-9 British Library Cataloguing in Publication Data Logic Program Synthesis and Transformation: Proceedings of LOPSTR 93. International Workshop on Logic Program Synthesis and Transformation. Louvain-Ia-Neuve. Belgium, 7-9 July 1993. - (Workshops in Computing Series) I. Deville, Yves ll. Series 005.1 ISBN-13:978-3-540-19864-2 Library of Congress Cataloging-in-Publication Data A catalog record for this book is available from the Library of Congress Apart from any fair dealing for the purposes of research or private study. or criticism or review, as permitted under the Copyright. Designs and Patents Act 1988. this publication may only be reproduced. stored or transmitted. in any form. or by any means, with the prior permission in writing of the publishers. or in the case of repro graphic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. ©British Computer Society 1994 The use of registered names. trademarks etc. in this publication does not imply. even in the absence of a specific statement, that such names arc exempt from the relevant laws and regulations and therefore free for general usc. The publisher makes no representation. express or implied. with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. Typesetting: Camera ready by contributors 34/3830-543210 Printed on acid-free paper Foreword This volume contains extended versions of papers presented at the Third International Workshop on Logic Program Synthesis and Transformation (LOPSTR 93) held in Louvain-la-Neuve in July 1993. Much of the success of the workshop is due to Yves Deville who served as Organizer and Chair. Many people believe that machine support for the development and evolution of software will play a critical role in future software engineering environments. Machine support requires the formalization of the artifacts and processes that arise during the software lifecycle. Logic languages are unique in providing a uniform declarative notation for precisely describing application domains, software requirements, and for prescribing behavior via logic programs. Program synthesis and transfonnation techniques formalize the process of developing correct and efficient programs from requirement specifications. The natural intersection of these two fields of research has been the focus of the LOPSTR workshops. The papers in this volume address many aspects of software develop- ment including: deductive synthesis, inductive synthesis, transforma- tions for optimizing programs and exploiting parallelism, program analysis techniques (particularly via abstract interpretation), meta- programming languages and tool support, and various extensions to Prolog-like languages, admitting non-Horn clauses, functions, and constraints. Despite the progress represented in this volume, the transition from laboratory to practice is fraught with difficulties. Some of the challenges that researchers face include (1) the development of techniques for handling more complex and realistic problems, (2) wider availability of implemented systems that can support experiments and education, and (3) support for software evolution. In future LOPSTR workshops we can look forward to continued progress in these areas and signs that the field is fulfilling its promise of radical improvements to software engineering practice. Palo Alto Douglas R. Smith October 1993 Preface LOPSTR 93, held from 7-9 July 1993, in Louvain-Ia-Ncuve, Belgium, is the third in a series of International Workshops on Logic Program Synthesis and Transformation. The aim of these meetings is to present recent work and to discuss new ideas and trends in logic program synthesis and transformation, as well as related fields. This year, the LOPSTR workshop was held jointly with the Program Development Area Meeting of Compunet, the Esprit Network in Computational Logic. The workshop brought together 55 researchers from 12 different countries, and 28 talks were presented. This volume contains 19 original contributions in logic program synthesis and transformation, including an invited paper from Douglas R. Smith. Our thanks to all the contributors to the workshop who made LOPSTR 93 a success. We would like to thank the other Program Committee members for their contribution and fruitful collaboration during the preparation of the workshop and the selection of papers. We thank them and the other referees for their detailed and timely refereeing of the submitted papers. We are most grateful to the Esprit Network in Computational Logic, and the Belgian National Fund for Scientific Research for their financial support. Special thanks to Vincent Lombart for his help in organizing the workshop and preparing these proceedings. Louvain-Ia-Neuve Yves Deville October 1993 Program Committee Danny De Schreye Katholieke Universiteit Leuven, Belgium Yves Deville (Chair) Universite Catholique de Louvain, Belgium Laurent Fribourg L.I.E.N.S., France John Gallagher University of Bristol, UK Kung-Kiu Lau University of Manchester, UK Baudouin Le Charlier University of Namur, Belgium Maurizio Proietti IASI - CNR Roma, Italy Referees M. Bouattour D. Boulanger M. Bruynooghe T. Clement L. De Raedt D. De Schreye Y. Deville P. Flener L. Fribourg J. Gallagher P. Hill J.-M. Jacquet J. Jones K.-K. Lau B. Le Charlier V. Lombart E. Marakakis B. Martens R. Moolenaar A. Pettorossi Contents Toward the Synthesis of Constraint Propagation Algorithms D.R. Smith (Invited Speaker).............................................. ................... 1 A Formal View of Specification, Deductive Synthesis and Transformation of Logic Programs K.-K. Lau and M. Ornaghi .................................................................. 10 Reachability Analysis for the Extension Procedure - A Topological Result G. Neugebauer ..................................................................................... 32 Inductive Synthesis of Logic Programs and Inductive Logic Programming F. Bergadano and D. Gunetti .............................................................. 45 Induction of Prolog Programs with Markus M. Grobelnik ..................... ....... ... .... ..... ....... ........ ......... ........................ 57 A General Technique for Automatically Generating Efficient Programs Through the Use of Proof Planning (Abstract) P. Madden. J. Hesketh. I. Green and A. Bundy................................. 64 Guiding Synthesis Proofs V. Lombart. G. Wiggins and Y. Deville .............................................. 67 Combining Prolog Programs in a Techniques Editing System (Abstract) M. Vargas-Vera. D. Robertson and R. Inder ..................................... 82 Designing Prolog Programming Techniques W. Weber Vasconcelos ........................................................................ 85 Interactive Program Derivation Using Program Schemata and Incrementally Generated Strategies A.-L. Johansson................................................................... ............... 100 The Power of Partial Evaluation D.A. de Waal...................................................................................... 113 Specialising the Ground Representation in the Logic Programming Language GMel C.A. Gurr ............................................................................................ 124 xii Contents Synthesis of Programs from UnfoldlFold Proofs M. Proietti and A. Pettorossi ............................................................ 141 Some Further Issues in Finite Unfolding (Abstract) B. Martens and D. De Schreye .......................................................... 159 A Transformation Based on the Equality Between Terms U. Neumerkel............................................................................ .......... 162 Automatic Exploitation of Non-Determinate Independent And-Parallelism in the Basic Andorra Model M. Olmedilla. F. Bueno and M. Hermenegildo ............................... 177 Memoing with Abstract Answers and Delphi Lemmas P. Tarau and K. De Bosschere .......................................................... 196 Using Abstract Interpretation for Goal Replacement D. Boulanger and M. Bruynooghe .................................................... 210 Mechanical Transformation of Logic Definitions Augmented with Type Information into Prolog Procedures: Some Experiments P. De Boeck and B. Le Charlier ....................................................... 229 Author Index ..................................................................................... 247 Toward the Synthesis of Constraint Propagation Algorithms * Douglas R. Smith Kestrel Institute 3260 Hillview Avenue Palo Alto, California 94304 USA 1 Introduction Within the last decade logic programming has developed into constraint logic programming. One motivation for this development has been the need to han- dle richer data structures in a manner consistent with the nondeterministic and relational style of logic programming. It was realized early on that ordinary unification was equation solving over trees. From there it was a natural step to allow equation solving over more complex structures (e.g. lists, booleans, inte- gers) and further to allow constraint solving in various theories (e.g. monoids, boolean algebras, real closed fields). From another point of view, constraint logic programming languages, such as PROLOG III [2], CLP(R) [5], and CHIP [4], can be seen as attempts to integrate the best features of logic programming and work on constraint satisfaction algorithms in Artificial Intelligence and Operations Research. See [1] for an overview of constraint logic programming. In a constraint program, a constraint set partially characterizes the objects of interest and their relationships. Constraint propagation is one of the key operations on constraints in constraint logic programming. As committments are made that further characterize some object, consequences of those com- mittments are inferred and added as new constraints. Efficiency concerns drive us to look closely at (1) the representation of constraints, (2) inference proce- dures for solving constraints and deriving consequences, and (3) the capture of inferred consequences as new constraints. It is natural to begin to consider the problem of synthesizing constraint logic programs. We report here on our current efforts at developing automated methods for deriving problem-specific constraint propagation code. This effort is part of a broader development of automated tools for transforming formal specifications into efficient and correct programs. The KIDS system [8] serves as the testbed for our experiments and provides tools for performing deductive inference, algorithm design, expression simplification, finite differencing, par- tial evaluation, data type refinement, and other transformations. We have used KIDS to derive over 60 algorithms for a wide variety of application domains, in- cluding scheduling, combinatorial design, sorting and searching, computational geometry, pattern matching, and mathematical programming. A transportation scheduling application motivated our constraint propaga- tion work [11]. The problem is NP-complete and is partly characterized by "This research was supported in part by ARPA/Rome Laboratories under Contract F30602-91-C-0043. in part by the Office of Naval Research under Grant N00014-90-J-1733. and in part by the Air Force Office of Scientific Research under Contract F49620-91-C-0073.