Integration of Prolog and Java with the Connector Architecture Capja

Integration of Prolog and Java with the Connector Architecture Capja

Julius-Maximilians-Universität Würzburg Fakultät für Mathematik und Informatik Dissertation Integration of Prolog and Java with the Connector Architecture CAPJa Ludwig Ostermayer February 2017 Supervisor: Prof. Dr. Dietmar Seipel Referees: Prof. Dr. Dietmar Seipel Prof. Dr. Grzegorz J. Nalepa Integration of Prolog and Java with the Connector Architecture CAPJa © 2017 Ludwig Ostermayer Julius-Maximilians-Universität Würzburg Fakultät für Mathematik und Informatik Am Hubland 97074 Würzburg Germany To Bernadette Abstract Modern software is often realized as a modular combination of subsystems for, e. g., knowledge management, visualization, verification, or the interaction with users. As a result, software libraries from possibly different programming languages have to work together. Even more complex the case is if different programming paradigms have to be combined. This type of diversification of programming languages and paradigms in just one software application can only be mastered by mechanisms for a seamless integration of the involved programming languages. However, the integration of the common logic programming language Prolog and the popular object-oriented programming language Java is complicated by various interoperabil- ity problems which stem on the one hand from the paradigmatic gap between the programming languages, and on the other hand, from the diversity of the available Prolog systems. The subject of the thesis is the investigation of novel mechanisms for the integration of logic programming in Prolog and object–oriented programming in Java. We are particularly interested in an object–oriented, uniform approach which is not specific to just one Prolog system. Therefore, we have first identified several important criteria for the seamless integration of Prolog and Java from the object–oriented perspective. The main contribution of the thesis is a novel integration framework called the Connector Architecture for Prolog and Java (CAPJa). The framework is completely implemented in Java and imposes no modifications to the Java Virtual Machine or Prolog. CAPJa provides a semi–automated mechanism for the integra- tion of Prolog predicates into Java. For compact, readable, and object–oriented queries to Prolog, CAPJa exploits lambda expressions with conditional and rela- tional operators in Java. The communication between Java and Prolog is based on a fully automated mapping of Java objects to Prolog terms, and vice versa. In Java, an extensible system of gateways provides connectivity with various Prolog system and, moreover, makes any connected Prolog system easily interchangeable, without major adaption in Java. Kurzbeschreibung Moderne Software ist oft modular zusammengesetzt aus Subsystemen zur Wis- sensverwaltung, Visualisierung, Verfikation oder Benutzerinteraktion. Dabei müssen Programmbibliotheken aus möglicherweise verschiedenen Programmiersprachen mit- einander zusammenarbeiten. Noch komplizierter ist der Fall, wenn auch noch ver- schiedene Programmierparadigmen miteinander kombiniert werden. Diese Art der Diversifikation an Programmiersprachen und –paradigmen in nur einer Software kann nur von nahtlosen Integrationsmechansimen für die beteiligten Programmier- sprachen gemeistert werden. Gerade die Einbindung der gängigen Logikprogram- miersprache Prolog und der populären objektorientierten Programmiersprache Java wird durch zahlreiche Kompatibilitätsprobleme erschwert, welche auf der einen Seite von paradigmatischen Unterschieden der beiden Programmiersprachen her- rühren und auf der anderen Seite von der Vielfalt der erhältlichen Prologimplemen- tierungen. Gegenstand dieser Arbeit ist die Untersuchung von neuartigen Mechanismen für die Zusammenführung von Logikprogrammierung in Prolog und objektorienter Programmierung in Java. Besonders interessiert uns dabei ein objektorientierter, einheitlicher Ansatz, der nicht auf eine konkrete Prologimplementierung festgelegt ist. Aus diesem Grund haben wir zunächst wichtige Kriterien für die nahtlose In- tegration von Prolog und Java aus der objetorientierten Sicht identifziert. Der Hauptbeitrag dieser Arbeit ist ein neuartiges Integrationssystems, welches Connec- tor Architecture for Prolog and Java (CAPJa) heißt. Das System ist komplett in Java implementiert und benötigt keine Anpassungen der Java Virtual Machine oder Prolog. CAPJa stellt einen halbautomatischen Mechanismus zur Vernetzung von Prolog Prädikaten mit Java zur Verfügung. Für kompakte, lesbare und ob- jektorientierte Anfragen an Prolog nutzt CAPJa Lambdaausdrücke mit logischen und relationalen Operatoren in Java. Die Kommunikation zwischen Java und Pro- log basiert auf einer automatisierten Abbildung von Java Objekten auf Prolog Terme, und umgekehrt. In Java bietet ein erweiterbares System von Schnittstellen Konnektivität zu einer Vielzahl an Prologimplmentierung und macht darüber hin- aus jede verbundene Prologimplementierung einfach austauschbar, und zwar ohne größere Anpassung in Java. Acknowledgements First of all, I would like to thank my mentor Professor Dr. Dietmar Seipel for in- troducing me to the wonderful world of logic programming, for his wise guidance, continuous support, and incredible patience without which this thesis would not have been possible. I also thank Professor Dr. Grzegorz J. Nalepa for countless valuable suggestions, important remarks, and fruitful discussions which had major impact on the work at hand. Moreover, I thank my colleague Frank Flederer for the close collaborations in the early stages of CAPJa and Dr. Joachim Spoerhase for his advice during the completion of this thesis. I also would like to express my thanks to Dr. Ulrike Rapp–Galmiche for proofreading this thesis. Finally, I would like to thank all students that have been involved in CAPJa in any manner, most notably Mirco Lukas and Andrew Easton. Last but not least, I would like to ex- press my gratitude to all my friends and my family for their consistent support and encouragement, most especially my dearest Bernadette. Contents Contents 1 Introduction1 1.1 Motivation, Scope, and Research Problem . .1 1.2 Goal of the Work and Original Contribution . .3 1.3 Introductory Examples . .6 1.4 Plan of the Work . .8 1.5 Exclusions . .9 1.6 Supporting Publications . .9 2 Selected Programming Paradigms and Languages 11 2.1 The Logic Programming Paradigm . 12 2.1.1 The Language of First-Order Logic . 12 2.1.2 Theory of Unification . 15 2.1.3 The Computational Model . 18 2.2 The Logic Programming Language Prolog .............. 21 2.2.1 Characteristics . 21 2.2.2 Important Language Concepts and Artifacts . 23 2.3 The Object-Oriented Programming Paradigm . 27 2.3.1 Objects and Classes . 27 2.3.2 Information Hiding and Encapsulation . 29 2.3.3 Types and Subtypes . 29 2.3.4 Inheritance and Polymorphy . 30 2.3.5 Dynamic Method Dispatch . 31 2.4 The Object-Oriented Programming Language Java .......... 31 2.4.1 Characteristics . 31 2.4.2 Important Language Concepts and Artifacts . 32 2.5 Synergy of Prolog and Java . 35 2.5.1 Advantages and Disadvantages of Prolog .......... 36 2.5.2 Advantages and Disadvantages of Java ............ 37 2.5.3 Synergy Effects . 39 3 Integration Approaches for Prolog and Java 41 3.1 Integration via Translation . 41 3.1.1 jProlog . 41 I Contents 3.1.2 Prolog Cafe . 42 3.2 Integration via Embedding . 45 3.2.1 tuProlog and P@J . 46 3.2.2 Smalltalk and SOUL ...................... 49 3.2.3 Logic Java . 51 3.3 Integration via Communication Interfaces . 54 3.3.1 Interprolog . 54 3.3.2 JPL . 57 3.3.3 PBR4J . 60 3.3.4 LogicObjects . 63 3.4 Alternative Approaches . 67 3.5 Synthesis . 68 3.5.1 Discussion . 69 3.5.2 Important Criteria for a Seamless Integration . 71 4 The Connector Architecture CAPJa 73 4.1 Components . 74 4.2 Development with CAPJa . 78 5 The JPMapping Component 81 5.1 Object-To-Term Mappings . 82 5.1.1 Introductory Example . 82 5.1.2 Formal Definition . 83 5.1.3 Default Mapping Mechanism . 86 5.1.4 Custom Mapping Definitions . 87 5.2 Predicate-Signature Notation . 91 5.2.1 Introductory Example . 92 5.2.2 Syntax and Semantics . 93 5.3 Implementation of Mappings . 95 5.3.1 The Abstract JPMapper<T> Class . 95 5.3.2 Subclassing JPMapper<T> .................... 96 5.3.3 Source Code Generation . 100 6 The JPLambda Component 105 6.1 Introductory Examples . 106 6.2 The Query Language JPQL . 109 6.2.1 Lambda Expressions . 109 6.2.2 Query Constraints . 110 6.2.3 Query Execution . 112 6.3 The Mapping Language JPML . 114 II Contents 6.4 JPCompiler . 116 6.4.1 Workflow . 117 6.4.2 Source Code Parsing . 119 6.4.3 The JPLambdaAnalyzer Class . 120 6.4.4 Generated Source Code . 121 6.4.5 Modified Source Code . 123 7 The JPGateway Component 125 7.1 The JPGateway Interface . 125 7.2 Dependencies . 127 7.3 The Portable Prolog Gateway . 129 7.4 Custom Gateways . 134 7.4.1 Remote Procedure Calls . 134 7.4.2 CAPJa as a High-Level API . 139 8 Evaluation 143 8.1 Case Study on the London Underground . 143 8.1.1 The Prolog Knowledge Base . 144 8.1.2 Queries from Java to Prolog ................. 145 8.1.3 Implementation with CAPJa . 147 8.1.4 Implementation with JPL . 148 8.1.5 Results . 150 8.2 Case Study on Taxes in International E-Commerce . 153 8.2.1 Logic Programming for Business Rules . 153 8.2.2 Delivery Threshold . 155 8.2.3 Business Objects . 155 8.2.4 Business Rules . 158 8.2.5 Calling the Business Rules . 160 8.2.6 Results . 162 8.3 Validation . 163 8.3.1 Applicability Revisited . 163 8.3.2 Important Criteria for a Seamless Integration Revisited . 165 9 Conclusion 173 9.1 Summary . 173 9.2 Future Work . 176 III List of Figures List of Figures 3.1 JFrame with 4 Buttons . 60 4.1 The Connector Architecture for Prolog and Java.......... 74 4.2 The JPMapping component of CAPJa. 76 5.1 The annotation layer of JPMapping.................. 88 5.2 The abstract JPMapper<T> class and its abstract methods. 95 5.3 Generating of subclasses of JPMapper<T> with JPMappingProcessor. 101 5.4 Generation of the object-oriented interface from Psn.......... 102 6.1 The Employee and the Address class in Java.............. 107 6.2 Extended build process with JPCompiler..............

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    208 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us