Lecture Notes in Computer Science Edited by G. Goos, J. Hartmanis and J. van Leeuwen 1048 Advisory Board: W. Brauer D. Gries J. Stoer
Maurizio Proietti (Ed.) Logic Program Synthesis and Transformation 5th International Workshop, LOPSTR' 95 Utrecht, The Netherlands September 20-22, 1995 Proceedings Springer
Series Editors Gerhard Goos, Karlsruhe University, Germany Juris Hartmanis, Cornell University, NY, USA Jan van Leeuwen, Utrecht University, The Netherlands Volume Editor Maurizio Proietti IASI-CNR Viale Manzoni 30, 1-00185 Rome, Italy Cataloging-in-Publication data applied for Die Deutsche Bibliothek - CIP-Einheitsaufnahme Logic program synthesis and transformation 9 5th international workshop ; proceedings / LOPSTR '95, Utrecht, The Netherlands, September 20-22, 1995. Maurizio Proietti (ed.). - Berlin ; Heidelberg ; New York ; Barcelona ; Budapest ; Hong Kong ; London ; Milan ; Paris ; Santa Clara ; Singapore ; Tokyo : Springer, 1996 (Lecture notes in computer science ; Vol. 1048) ISBN 3-540-60939-3 NE: Proietti, Maurizio [Hrsg.]; LOPSTR <5, 1995, Utrecht>; GT CR Subject Classification (1991): D.1.2, 1.2.2, D,1.6,E4.1, F.3.1 ISBN 3-540-60939-3 Springer-Verlag Berlin Heidelberg New York This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, re-use of illustrations, recitation, broadcasting, reproduction on microfilms or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer -Verlag. Violations are liable for prosecution under the German Copyright Law. 9 Springer-Verlag Berlin Heidelberg 1996 Printed in Germany Typesetting: Camera-ready by author SPIN 10512651 06/3142-5 4 3 2 1 0 Printed on acid-free paper
Foreword Program transformation is a very powerful methodology for the development of correct and efficient programs. In applying this methodology one usually assumes that an initial program version (or a program specification) is given and it is required to derive a new program (or an implementation of the given specification). Since program specifications are often given as formulas in a logical theory, it is particularly important to study the transformation methodology in the case of logic programming. The field of program derivation by transformation is very closely related to the field of program synthesis. In these fields, in fact, similar techniques of formula manipulation are used. For this reason it is appropriate to study the techniques for Logic Program Synthesis and Transformation as a single set of related methodologies. This is the aim of the LoPSTr workshops. During the past years, these workshops have been very fruitful and stimulating. Their success also shows the importance and the relevance of the synthesis and transformation of logic programs within the area of theoretical computer science and its practical applications. Other areas of artificial intelligence and programming methodologies are connected to logic program synthesis and transformation. Papers from these areas have been presented and discussed in previous LoPSTr workshops and in LoP- STr'95 as well. Among these areas I would like to mention: i) Constructive type theory, by which one may synthesize programs from a constructive proof of the existence of an element of a given type, ii) Inductive logic programming, which studies the problem of synthesizing logic programs from examples and counterexamples, iii) Abstract interpretation and program analysis, which aims at proving properties of programs by interpreting the concrete operations of the programs in some given abstract domains, iv) Partial evaluation (or partial deduction), by which one derives new and more efficient programs by exploiting some information on the values of the input variables, and v) Theorem proving, which studies the different techniques of making proofs within various logical theories. Now I would like to list some desirable properties of the derivation steps which support the development of logic programs. These properties should be taken into account when designing a system for logic program synthesis and/or transformation. I will list those properties with reference to the program transformation process, but I think that they are of great importance also in the case of program synthesis. 1. First of all, it is desirable that every derivation step be constructive, that is, program Pi+l should be derived from program Pi by the application of a constructive transformation rule. I will not formally specify here the notion of constructive rule. It will be enough to say that rewriting rules of the kind one uses in rewriting systems, that is, rules which are based on: i) syntactic matching, and ii) rewriting of old expressions by new expressions, are
VI constructive. Thus, for instance, the usual schema-based program transformation rules are considered to be constructive. By contrast, non-constructive rules are, for instance, those whose application needs the solution of a problem which is undecidable. 2. Some derivation steps can be lemmatic. The meaning of this property is that when performing transformation steps, we allow ourselves to use lemmas, and these lemmas can be proved off-line (possibly, by taking advantage of some ad hoc theorem provers). This feature of the program derivation process is of major importance, because it is often the case that only by the use of lemmas can one derive very efficient programs. Indeed, for instance, linear running time algorithms for the evaluation of linear recurrence relations can be derived from given exponential running time algorithms, only if the functionality of some relevant predicates is proved. 3. Some derivation steps should allow substitutivity. The meaning of this property is that when a subformula, say 9, of a given program, say P~, is shown (using i0rogram Pi) to be equivalent to a formula r then we may get a new program Pi+l by replacing ~ by r within Pi. This substitution should preserve the semantics of Pi, and it is performed for changing the behaviour of Pi so that, for instance, the computations evoked by Pi+l are more efficient than those evoked by Pi. (Here we assume that new programs are derived from old programs with the aim of improving efficiency.) Notice also that, although the equivalence of ~ and r is derived from Pi, the replacement of ~ by r within Pi may change the semantics of Pi. For instance, from the simple formula (or program) a ~-* b, obviously one may derive the equivalence a ~ b. Thus, by replacing within a ~ b the expression b by the equivalent expression a, we get the new program a ~ a which is not equivalent to the original program. Finally, the reader should notice that constructive, lemmatic, and substitutive derivation steps allow for machine assistance. This is important, in particular, when the size of the programs to be derived becomes considerably large, and indeed, such mechanization makes it possible to propose the derivation methodology as a valuable technique for real-life programming. l~me January 1996 Alberto Pettorossi
Preface This volume contains the 19 papers presented at the Fifth International Workshop on Logic Program Synthesis and Transformation, LoPSTr'95, held near Utrecht (The Netherlands), September 20-22, 1995. Previous LoPSTr workshops were held in Manchester, U.K. (1991 and 1992), Louvain-la-Neuve, Belgium (1993), and Pisa, Italy (1994). The aim of the LoPSTr workshops is to stimulate new ideas and research in the field of machine-assisted development of logic programs. The main topics of interest are: program synthesis, program transformation, and program specialization. The papers presented at LoPSTr'95 give an up-to-date overview of the current research on these topics, as well as related topics in the field of program development, such as: automated deduction, constructive type theory, implementation techniques, inductive logic programming, meta-languages, program analysis, program specification, program verification, and software engineering. LoPSTr'95 was organized in parallel with PLILP'95 (Seventh Symposium on Programming Languages: Implementations, Logics, and Programs). The overall attendance at the two meetings was about 110 people from 21 countries. Out of 40 submissions, the Program Committee selected 19 papers for presentation. After the workshop, 17 papers were submitted in their revised versions which took into account the discussion at the workshop and the comments by the referees. These papers underwent a second refereeing process and they were further revised. The two remaining presentations are recorded in these proceedings as abstracts. Most submissions, the referee reports, and the discussion among the members of the Program Committee were done by electronic mail. Several hundred electronic mail messages concerning LoPSTr'95 have been delivered to my mailbox. LoPSTr'95 and PLILP'95 shared three invited lectures which were given by Mark Jones (Nottingham, U.K.), Oege de Moor (Oxford, U.K.), and Kim Marriott (Melbourne, Australia). The papers presented by the invited lecturers appear in the PLILP'95 proceedings (Lecture Notes in Computer Science, Vol. 982, Springer-Verlag). I would hike to thank all those who contributed to making LoPSTr'95 a successful and fruitful event. In particular, my gratitude goes to the researchers who submitted the papers, the referees, the members of the Program Committee, and the various agencies which provided financial support. Special thanks go to Prof. Doaitse Swierstra and his colleagues of Utrecht University for their invaluable work which allowed the workshop to run very smoothly and in a pleasant environment. I also would like to thank Alberto Pettorossi for his continuous advice and help. Finally, I would like to give my warmest thanks to all participants who contributed, by means of lively discussions, to making LoPSTr'95 a very stimulating event. Rome January 1996 Maurizio Proietti
viii Program Committee A. Bossi D. Boulanger S. Debray Y. Deville L. Fribourg N. Fuchs J. Gallagher T. Mogensen M. Proietti It. Seki P, Tarau G. Wiggins (Universits della Calabria, Rende, Italy) (Katholieke Universiteit Leuven, Belgium) (University of Arizona, Tucson, USA) (Universit@ Catholique de Louvain, Belgium) (LIENS-CNRS, Paris, France) (University of Zurich, Switzerland) (University of Bristol, U.K.) (University of Copenhagen, Denmark) (IASI-CNR, Roma, Italy, chair) (NIT, Nagoya, Japan) (University of Moncton, Canada) (University of Edinburgh, U.K.) Organizing Committee Jeroen Fokker, Erik Meijer, Margje Punt, Doaitse Swierstra Sponsors (of LoPSTr'95 and PLILP'95) European Commission - ESPRIT Basic Research (CompuLog-Net) Royal Dutch Academy of Sciences (KNAW) The Netherlands Computer Science Research Foundation (SION) The Association of Logic Programming IASI-CNR (National Research Council of Italy) Universiteit Utrecht List of Referees The following people helped the Program Committee in refereeing the papers submitted to LoPSTr'95: Michel Bidoit, Michele Bugliesi, Nicoletta Cocco, Livio Colussi, Sandro Etalle, Gilberto Fil@, Robert Gliick, Neil Jones, Vincent Lombart, Tadashi Kawamura, Alberto Pettorossi, Jakob Rehof, Taisuke Sato, Morten Heine Sorensen, Wamberto Vasconcelos.
Table of Contents Ecological Partial Deduction: Preserving Characteristic Trees Without Constraints... 1 Michael Leuschel Memoing Evaluation by Source-to-Source Transformation... 17 Jens E. Wunderwald Transformation of Left Terminating Programs: The Reordering Problem... 33 Annalisa Bossi, Nicoletta Cocco, and Sandro Etalle Derivation of Concurrent Algorithms in Tempo... 46 Steve Gregory An Argumentation-Theoretic Approach to Logic Program Transformation... 61 Francesca Toni and Robert A. Kowalski Complexity of Horn Programs... 76 Erik Aarts Studying the Cost of Logic Languages in an Abstract Interpretation Framework for Granularity Analysis... 91 M.M. Gallardo and J.M. Troya Towards Automatic Control for CLP(x) Programs... 106 Fred Mesnard Ideal Refinement of Datalog Programs... 120 Giovanni Semeraro, Floriana Esposito, and Donato Malerba Guiding Program Development Systems by a Connection Based Proof Strategy... 137 Cristoph I(reitz, Jens Otten, and Stephan Schmitt Towards an Object-Oriented Methodology for Deductive Synthesis of Logic Programs... 152 Kung-Kiu Lau and Mario Ornaghi Logic Program Synthesis by Induction over Horn Clauses... 170 Andrew J. Parkes and Geraint A. Wiggins Logic Program Transformation Through Generalization Schemata... 171 Pierre Flener and Yves Deville
An Opportunistic Approach for Logic Program Analysis and Optimisation Using Enhanced Schema-Based Transformations... 174 Wamberto W. Vasconcelos and Norberr E. Fuchs Solving Deductive Planning Problems Using Program AnMysis and Transformation... 189 D.A. de Waal and M. Thielscher Towards a Complete Proof Procedure to Prove Properties of Normal Logic Programs Under the Completion... 204 Sophie Renault Termination of Logic Programs Using Semantic Unification... 219 Thomas Arts and Hans Zantema On the Mechanics of Metasystem Hierarchies in Program Transformation... 234 Robert Gliick Efficient Translation of Lazy Functional Logic Programs into Prolog... 252 Michael Hanus Author Index... 267