Representation of Compositional Relational Programs
Total Page:16
File Type:pdf, Size:1020Kb
Representation of Compositional Relational Programs Representation of Compositional Relational Programs Görkem Paçacı Dissertation presented at Uppsala University to be publicly examined in Lecture hall 2, Ekonomikum, Uppsala, Friday, 28 April 2017 at 13:00 for the degree of Doctor of Philosophy. The examination will be conducted in English. Faculty examiner: Professor Alberto Pettorossi (University of Rome Tor Vergata). Abstract Paçacı, G. 2017. Representation of Compositional Relational Programs. 216 pp. Uppsala: Department of Informatics and Media, Uppsala University. ISBN 978-91-506-2621-6. Usability aspects of programming languages are often overlooked, yet have a substantial effect on programmer productivity. These issues are even more acute in the field of Inductive Synthesis, where programs are automatically generated from sample expected input and output data, and the programmer needs to be able to comprehend, and confirm or reject the suggested programs. A promising method of Inductive Synthesis, CombInduce, which is particularly suitable for synthesizing recursive programs, is a candidate for improvements in usability as the target language Combilog is not user-friendly. The method requires the target language to be strictly compositional, hence devoid of variables, yet have the expressiveness of definite clause programs. This sets up a challenging problem for establishing a user-friendly but equally expressive target language. Alternatives to Combilog, such as Quine's Predicate-functor Logic and Schönfinkel and Curry's Combinatory Logic also do not offer a practical notation: finding a more usable representation is imperative. This thesis presents two distinct approaches towards more convenient representations which still maintain compositionality. The first is Visual Combilog (VC), a system for visualizing Combilog programs. In this approach Combilog remains as the target language for synthesis, but programs can be read and modified by interacting with the equivalent diagrams instead. VC is implemented as a split-view editor that maintains the equivalent Combilog and VC representations on-the-fly, automatically transforming them as necessary. The second approach is Combilog with Name Projection (CNP), a textual iteration of Combilog that replaces numeric argument positions with argument names. The result is a language where argument names make the notation more readable, yet compositionality is preserved by avoiding variables. Compositionality is demonstrated by implementing CombInduce with CNP as the target language, revealing that programs with the same level of recursive complexity can be synthesized in CNP equally well, and establishing the underlying method of synthesis can also work with CNP. Our evaluations of the user-friendliness of both representations are supported by a range of methods from Information Visualization, Cognitive Modelling, and Human-Computer Interaction. The increased usability of both representations are confirmed by empirical user studies: an often neglected aspect of language design. Keywords: Programming, Syntax, Logic Programming, Combilog, CombInduce, Prolog, Variable-free, Point-free, Tacit, Compositional Relational Programming, Combinatory Logic, Predicate-Functor Logic, Program Synthesis, Meta-interpreters, Meta-interpretative Synthesis, Decompositional Synthesis, Inductive Synthesis, Inductive Logic Programming, Usability, Cognitive Dimensions of Notations, Visual Variables, Usability testing, Programming Language usability, Empirical evidence Görkem Paçacı, Department of Informatics and Media, Information Systems, Kyrkogårdsg. 10, Uppsala University, SE-751 20 Uppsala, Sweden. © Görkem Paçacı 2017 ISBN 978-91-506-2621-6 urn:nbn:se:uu:diva-317084 (http://urn.kb.se/resolve?urn=urn:nbn:se:uu:diva-317084) Acknowledgements This journey was made possible and enjoyable thanks to the support and fellowship of these lovely people. I shall express my gratitude and appreciation, To my invaluable advisor Prof. Dr. Andreas Hamfelt. I would not have been able to chart my way through and concluded this work, if it was not for your continuous and unlimited support. It is impossible to overstate how grateful I am to have you as a friend, guide, and family. I hope I didn’t consume all your patience and you still have some left for future students. It was a privilege and honour to learn from you, and I hope to do so for many years to come. To Dr. Steve McKeever for tirelessly reading, commenting, and con- tributing with his ideas to this work. I shall miss your witty remarks, and your comments written with your intimidating bright red pen. To Prof. Dr. Jørgen Fischer Nilsson for his contributions and for his insightful comments in various stages of this work. To my lovely, caring wife Neşe, for putting up with me all the times my mind was away, and filling my life with cheer, beauty and delight. I will finally have some time to enjoy you. To my dear mother Nilüfer for letting me go far and always supporting me. To my dear father Levent for always encouraging me for more. To Süheyla for her support, and giving me two lovely sisters. To my dear sister Aylin for always intriguing me. To my dear sister Deniz for always entertaining me, and for designing this brilliant cover (with inspiration from Felix Prax). To my gleeful aunts Nükhet and Funda, and to my lively cousins Hande, Betül, Mertcan, Buse and Nehir. To my dear friends Serkan Barut, Dr. Onur Yılmaz, Dr. Selva Baziki, and Dr. Ali Sina Önder for all the fun times and reassuring me I’ll get to the finish line. To all past and current Ph.D. students in Informatics and Media, for making this place as cosy and crazy as it is. Thank you for the cama- raderie Siddharth Chadha, Kirill Filimonov, Dr. Sylvain Firer-Blaess, Dr. Mareike Glöss, Cristina Ghita, Dr. Anders Larsson, Ruth Lochan, Daniel Lövgren, Dr. Elena Márquez, Mudassir Imran Mustafa, Dr. Patrick Prax, Hafijur Mohammad Rahman, Asma Rafiq, Paulina Rajkowska, Martin Stojanov, Dr. Emma Svensson, Christopher Okhravi, Laia Turmo Vidal, Dr. Stanislaw Zabramski. To all the nice people in IM, for making my years here pleasant and cheerful, and making IM a cool and warm place to work at, and never passing an opportunity to party. Thank you Anton Backe, Mikael Berg, Carina Boson, Ylva Ekström, Dr. Jenny Eriksson Lundström, Prof. Dr. Mats Edenius, Dr. Anneli Edman, Eva Enefjord, Madelen Hermelin, Mar- tin Landahl, Prof. Dr. Mats Lind, Eva Karlsson, Tina Kekkonen, Jakob Malmstedt, Dr. Therese Monstad, Mattias Nordlindh, Dr. Else Nygren, Mathias Peters, Sofie Roos, Klara Runesson, Christian Sandström, Sophie Skogehall, Christer Stuxberg, Lars-Göran Svensk, Dr. Göran Svensson, Dr. Claes Thorén, Dr. Franck Tétard, Prof. Dr. Sten-Åke Tärnlund, Prof. Dr. Annika Waern, GunBritt Wass, Prof. Dr. Vladislav Valkovsky, Prof. Dr. Pär Ågerfalk. To Dr. David Johnston, for reading multiple versions of this thesis without getting tired of it. To my professors and colleagues in Izmir, especially to Prof. Dr. Brahim Hnich, Prof. Dr. Cemali Dinçer and Dr. Mahmut Ali Gökçe. To my dear friends Dr. Umut Avcı and Dr. Kaya Oğuz, with whom we started a journey that unpredictably lead me to Uppsala. To Dr. Özgür Akgün and Dr. Migual Nacenta for their support and hospitality in St Andrews. To everyone who contributed their valuable time to participate in the user studies in this thesis. To the Smålands nation in Uppsala, and the Anna Maria Lundin’s Fund for generously supporting this work with multiple grants throughout the years. 6 Contents 1 Introduction ............................................................................ 11 1.1 Compositionality ............................................................. 13 1.2 Compositional relational argument binding problem .......... 16 1.3 Method .......................................................................... 21 1.4 Related work .................................................................. 23 1.4.1 Combinatory Logic .............................................. 24 1.4.2 Relational calculi ................................................ 25 1.4.3 De Bruijn indices ................................................ 25 1.4.4 Nominal logic ..................................................... 26 1.4.5 Compositional Logic Programming ....................... 26 1.5 Contributions ................................................................. 27 1.6 Overview ........................................................................ 29 2 Background ............................................................................. 30 2.1 Logic Programming ......................................................... 30 2.1.1 First-order logic .................................................. 30 2.1.2 Definite clause programs ...................................... 32 2.1.3 Model-theoretic semantics ................................... 33 2.1.4 Fixpoint semantics .............................................. 35 2.1.5 Proof-theoretic semantics ..................................... 36 2.2 Combilog ........................................................................ 40 2.2.1 Compositional Relational Programming ................ 40 2.2.2 Elementary predicates ......................................... 41 2.2.3 Projection operator make .................................... 42 2.2.4 Logic operators ................................................... 43 2.2.5 Sample predicate append ..................................... 44 2.2.6 Recursion operators ...........................................