Qian Wang Ph.D. Dissertation
Total Page:16
File Type:pdf, Size:1020Kb
A SEMANTICS-BASED APPROACH TO PROCESSING FORMAL LANGUAGES by Qian Wang APPROVED BY SUPERVISORY COMMITTEE: ___________________________________________ Gopal Gupta, Chair ___________________________________________ Dung T. Huynh ___________________________________________ Lawrence Chung ____________________________________________ Jing Dong Copyright 2007 Qian Wang All Rights Reserved To my wife Haiying, lovely daughter Selina A SEMANTICS-BASED APPROACH TO PROCESSING FORMAL LANGUAGES by QIAN WANG, B.S., M.S. DISSERTATION Presented to the Faculty of The University of Texas at Dallas in Partial Fulfillment of the Requirements for the Degree of DOCTOR OF PHILOSOPHY IN COMPUTER SCIENCE THE UNIVERSITY OF TEXAS AT DALLAS December, 2007 ACKNOWLEDGEMENTS I am deeply indebted to my supervisor, Professor Gopal Gupta, for his guidance, insight and encouragement through the course of doctoral program and for his careful reading and constructive criticisms and suggestions on the dissertation and research work. I would like to thank members of my committee for agreeing to serve in the committee and for their feedback. I am also grateful to the many anonymous referees who have reviewed parts of this work prior to publication in conference proceedings and whose valuable comments have contributed to the clarifications of the ideas presented in this thesis. While doing my research work I have been supported by grants from the National Science Foundation, the U.S. Department of Education and the Environmental Protection Agency. I have also received support from the Erik Jonsson School of Engineering and Computer Science. For all this support, I am very grateful. I would also like to acknowledge the help of Dan Sahlin of the Swedish Institute of Computer Science, Ericsson, the author of Mixtus Partial Evaluation System, and Michael Leuschel of the University of Dusseldorf and the author of LOGEN Partial Evaluation system. I am also grateful to Constance Heitmeyer and Elizabeth Leonard of the Naval Research Labs for help with SCR. I give my gratitude to Ajay Bansal and Vidya Kona for their help in proof-reading my dissertation. v I also thank my parents Wang Jianhua and Cai Yuejiao for their care and encouragement in my years of study. Finally, I sincerely thank my wife Wang Haiying and my lovely daughter Selina for their complete support during the course of my Ph.D. studies. November 2007 vi A SEMANTICS-BASED APPROACH TO PROCESSING FORMAL LANGUAGES Publication No. ___________________ Qian Wang, Ph.D. The University of Texas at Dallas, 2007 Supervising Professor: Gopal Gupta ABSTRACT There is a large semantic gap between the level at which a solution to a problem is conceived by a domain expert or a requirements engineer and the level at which it is programmed on a computer. Traditional approaches to minimizing the impact of this gap have been based on using modeling languages and/or domain specific languages that have clear formal semantics. Designing the modeling or domain specific language is not enough, as many problems still remain. These problems pertain to being able to rapidly develop an implementation infrastructure for the language in a provably correct manner and being able to interoperate between multiple languages proposed for a given domain. In this dissertation we propose and develop a semantics-based framework---founded on Horn Logical Denotational Semantics---to solve these problems. We show how our approach can be used for rapidly obtaining the implementation infrastructure (interpreter, compiler, debugger, and profiler) for domain specific languages in a provably correct manner, as well as for working with multiple domain specific language in an interoperable manner. We also show how our approach works even in presence of unstructured control constructs. vii TABLE OF CONTENTS Acknowledgements..............................................................................................................v Abstract............................................................................................................................. vii List of ILLUSTRATIONS................................................................................................. xi CHAPTER 1 INTRODUCTION AND OVERVIEW .......................................................1 1.1 Motivation....................................................................................................1 1.2 Research Problems.......................................................................................4 1.3 The Structure of the Dissertation .................................................................6 CHAPTER 2 BACKGROUND AND RELATED WORKS.............................................7 2.1 Introduction..................................................................................................7 2.2 Formal Language .........................................................................................7 2.3 Denotational Semantics ...............................................................................8 2.4 Horn Clause and Logic Programming .......................................................10 2.5 Partial Evaluation.......................................................................................11 2.6 Domain Specific Languages ......................................................................13 2.7 Architecture Description Languages..........................................................15 2.7.1 What is ADL? ................................................................................15 2.7.2 Qualities of an ADL.......................................................................15 2.7.3 Why need ADLs?...........................................................................16 2.7.4 Brief Survey of ADLs....................................................................16 CHAPTER 3 RAPIDLY PROTOTYPING IMPLEMENTATION INFRASTRUCTURE OF DOMAIN SPECIFIC LANGUAGE..................................................................................20 3.1 Introduction................................................................................................20 3.2 Horn Logic Denotations.............................................................................23 3.3 Software Engineering and Domain Specific Languages ...........................25 3.4 A Domain Specific Language for File-Editor Commands ........................27 viii 3.5 Practical Issues in DCG Based Parsing .....................................................31 3.6 Provably Correct Compilation ...................................................................37 3.7 Automatic Generation of Debuggers and Profilers....................................40 3.8 Application of SCR....................................................................................41 3.8.1 SCR: Software Cost Reduction Method ........................................41 3.8.2 The Four-Variable Model ..............................................................42 3.8.3 An Interpreter & a Compiler for SCR............................................43 3.8.4 Generating SCR's Debugger ..........................................................47 3.9 Related Work .............................................................................................49 3.10 Conclusions................................................................................................51 CHAPTER 4 TOWARDS PROVABLY CORRECT CODE GENERATION VIA HORN LOGICAL CONTINUATION SEMANTICS...................................................................52 4.1 Introduction................................................................................................52 4.2 Horn Logical Semantics.............................................................................55 4.3 Definite Clause Semantics .........................................................................61 4.4 Continuation Semantics .............................................................................67 4.5 Related Work .............................................................................................75 4.6 Conclusions................................................................................................77 CHAPTER 5 INTEGRATING ADL BASED ON SEMANTIC APPROACH ..............78 5.1 Motivation..................................................................................................78 5.2 Semantics-based Approach to Integration .................................................83 5.2.1 A Framework for Integrating ADLs ..............................................83 5.2.2 Horn Logical Denotational Semantics...........................................87 5.3 Internal Expression of Architecture Information.......................................89 5.4 Definition of Query Language...................................................................93 5.5 An Interpreter for ADLs to Build Internal Abstract Expression................96 5.5.1 Build Parse Tree.............................................................................97 5.5.2 Define Semantic algebra for ADLs................................................98 5.5.3 Mapping Semantics........................................................................98 5.6 An interpreter for Query Language and Format result information ........100 5.7 Four simple Examples of Query Language .............................................101 5.8 Related Work ...........................................................................................104 ix 5.9 Conclusions..............................................................................................106