Functional and Constraint Logic Programming
Total Page:16
File Type:pdf, Size:1020Kb
Lecture Notes in Computer Science 6816 Commenced Publication in 1973 Founding and Former Series Editors: Gerhard Goos, Juris Hartmanis, and Jan van Leeuwen Editorial Board David Hutchison Lancaster University, UK Takeo Kanade Carnegie Mellon University, Pittsburgh, PA, USA Josef Kittler University of Surrey, Guildford, UK Jon M. Kleinberg Cornell University, Ithaca, NY, USA Alfred Kobsa University of California, Irvine, CA, USA Friedemann Mattern ETH Zurich, Switzerland John C. Mitchell Stanford University, CA, USA Moni Naor Weizmann Institute of Science, Rehovot, Israel Oscar Nierstrasz University of Bern, Switzerland C. Pandu Rangan Indian Institute of Technology, Madras, India Bernhard Steffen TU Dortmund University, Germany Madhu Sudan Microsoft Research, Cambridge, MA, USA Demetri Terzopoulos University of California, Los Angeles, CA, USA Doug Tygar University of California, Berkeley, CA, USA Gerhard Weikum Max Planck Institute for Informatics, Saarbruecken, Germany Herbert Kuchen (Ed.) Functional and Constraint Logic Programming 20th International Workshop, WFLP 2011 Odense, Denmark, July 19, 2011 Proceedings 13 Volume Editor Herbert Kuchen Westfälische Wilhelms-Universität Münster Institut für Wirtschaftsinformatik Leonardo-Campus 3, 48149 Münster, Germany E-mail: [email protected] ISSN 0302-9743 e-ISSN 1611-3349 ISBN 978-3-642-22530-7 e-ISBN 978-3-642-22531-4 DOI 10.1007/978-3-642-22531-4 Springer Heidelberg Dordrecht London New York Library of Congress Control Number: 2011931683 CR Subject Classification (1998): F.4, F.3.2, D.3, I.2.2-5, I.1 LNCS Sublibrary: SL 1 – Theoretical Computer Science and General Issues © Springer-Verlag Berlin Heidelberg 2011 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. Violations are liable to prosecution under the German Copyright Law. The use of general descriptive names, registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. Typesetting: Camera-ready by author, data conversion by Scientific Publishing Services, Chennai, India Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com) Preface This volume contains the proceedings of the 20th International Workshop on Functional and (Constraint) Logic Programming (WFLP 2011), held in Odense, Denmark, July 19, 2011 at the University of Southern Denmark. WFLP aims at bringing together researchers interested in functional programming, (constraint) logic programming, as well as the integration of the two paradigms. It promotes the cross-fertilizing exchange of ideas and experiences among researchers and students from the different communities interested in the foundations, appli- cations and combinations of high-level, declarative programming languages and related areas. The previous editions of this workshop were: WFLP 2010 (Madrid, Spain), WFLP 2009 (Brasilia, Brazil), WFLP 2008 (Siena, Italy), WFLP 2007 (Paris, France), WFLP 2006 (Madrid, Spain), WCFLP 2005 (Tallinn, Estonia), WFLP 2004 (Aachen, Germany), WFLP 2003 (Valencia, Spain), WFLP 2002 (Grado, Italy), WFLP 2001 (Kiel, Germany), WFLP 2000 (Benicassim, Spain), WFLP 1999 (Grenoble, France), WFLP 1998 (Bad Honnef, Germany), WFLP 1997 (Schwarzenberg, Germany), WFLP 1996 (Marburg, Germany), WFLP 1995 (Schwarzenberg, Germany), WFLP 1994 (Schwarzenberg, Germany), WFLP 1993 (Rattenberg, Germany), and WFLP 1992 (Karlsruhe, Germany). Since its 2009 edition, the WFLP proceedings have been published by Springer in its Lec- ture Notes in Computer Science series, as volumes 5979 and 6559, respectively. Each submission of WFLP 2011 was peer-reviewed by at least three Program Committee members with the help of some external experts. The Program Com- mittee meeting was conducted electronically in May 2011 with the help of the conference management system EasyChair. After careful discussions, the Pro- gram Committee selected ten submissions for presentation at the workshop. Nine of them were considered mature enough to be published in these proceedings. On behalf of the Program Committee, I would like to thank all researchers, who gave talks at the workshop, contributed to the proceedings, and submitted papers to WFLP 2011. As Program Chair, I would also like to thank all mem- bers of the Program Committee and the external reviewers for their careful work. Moreover, I am pleased to acknowledge the valuable assistance of the conference management system EasyChair and to thank its developer Andrei Voronkov for providing it. Finally, all the participants of WFLP 2011 and I are deeply indebted to Peter Schneider-Kamp and his team, who organized the Odense Summer on Logic and Programming, which besides WFLP comprised the 21st International Symposium on Logic-Based Program Synthesis and Transformation (LOPSTR 2011), the 13th International ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming (PPDP 2011), and the 4th International Workshop on Approaches and Applications of Inductive Programming (AAIP 2011). All the local organizers did a wonderful job and provided invaluable sup- port in the preparation and organization of the overall event. May 2011 Herbert Kuchen Organization Program Chair Herbert Kuchen University of M¨unster, Germany Program Committee Mar´ıa Alpuente Universidad Polit´ecnica de Valencia, Spain Sergio Antoy Portland State University, USA Rafael Caballero-Rold´an Universidad Complutense, Madrid, Spain Olaf Chitil University of Kent, UK Rachid Echahed Institut IMAG, Laboratoire Leibniz, France Santiago Escobar Universidad Polit´ecnica de Valencia, Spain Moreno Falaschi University of Siena, Italy Sebastian Fischer National Institute of Informatics, Tokyo, Japan Michael Hanus Christian-Albrechts-Universit¨at Kiel, Germany Julio Mari˜no y Carballo Universidad Polit´ecnica de Madrid, Spain Janis Voigtl¨ander Universit¨at Bonn, Germany Additional Reviewers Demis Ballis Ra´ul Gutierrez Pablo Nogueira Local Organization Chair Peter Schneider-Kamp University of Southern Denmark, Odense, Denmark Table of Contents Functional Logic Programming KiCS2: A New Compiler from Curry to Haskell ...................... 1 Bernd Braßel, Michael Hanus, Bj¨orn Peem¨oller, and Fabian Reck New Functional Logic Design Patterns .............................. 19 Sergio Antoy and Michael Hanus XQuery in the Functional-Logic Language Toy ....................... 35 Jesus M. Almendros-Jim´enez, Rafael Caballero, Yolanda Garc´ıa-Ruiz, and Fernando S´aenz-P´erez Functional Programming Size Invariant and Ranking Function Synthesis in a Functional Language ....................................................... 52 Ricardo Pe˜na and Agustin D. Delgado-Mu˜noz Memoizing a Monadic Mixin DSL .................................. 68 Pieter Wuille, Tom Schrijvers, Horst Samulowitz, Guido Tack, and Peter Stuckey A Functional Approach to Worst-Case Execution Time Analysis ....... 86 V´ıtor Rodrigues, M´ario Florido, and Sim˜ao Melo de Sousa Building a Faceted Browser in CouchDB Using Views on Views and Erlang Metaprogramming ......................................... 104 Claus Zinn Integration of Constraint Logic and Object-Oriented Programming Logic Java: Combining Object-Oriented and Logic Programming ....... 122 Tim A. Majchrzak and Herbert Kuchen Term Rewriting On Proving Termination of Constrained Term Rewrite Systems by Eliminating Edges from Dependency Graphs ........................ 138 Tsubasa Sakata, Naoki Nishida, and Toshiki Sakabe Author Index .................................................. 157 KiCS2: A New Compiler from Curry to Haskell Bernd Braßel, Michael Hanus, Bj¨orn Peem¨oller, and Fabian Reck Institut f¨ur Informatik, CAU Kiel, D-24098 Kiel, Germany {bbr,mh,bjp,fre}@informatik.uni-kiel.de Abstract. In this paper we present our first steps towards a new system to com- pile functional logic programs of the source language Curry into purely func- tional Haskell programs. Our implementation is based on the idea to represent non-deterministic results as values of the data types corresponding to the results. This enables the application of various search strategies to extract values from the search space. We show by several benchmarks that our implementation can compete with or outperform other existing implementations of Curry. 1 Introduction Functional logic languages integrate the most important features of functional and logic languages (see [8,24] for recent surveys). In particular, they combine higher-order func- tions and demand-driven evaluation from functional programming with logic program- ming features like non-deterministic search and computing with partial information (logic variables). The combination of these features has led to new design patterns [6] and better abstractions for application programming, e.g., as shown for programming with databases [14,18], GUI programming [21], web programming [22,23,26], or string parsing [17]. The implementation of functional logic languages is challenging since a reasonable