A Study of Semantics, Types and Languages for Databases and Object-Oriented Programming
Total Page:16
File Type:pdf, Size:1020Kb
University of Pennsylvania ScholarlyCommons Technical Reports (CIS) Department of Computer & Information Science October 1989 A Study of Semantics, Types and Languages for Databases and Object-Oriented Programming Atsushi Ohori University of Pennsylvania Follow this and additional works at: https://repository.upenn.edu/cis_reports Recommended Citation Atsushi Ohori, "A Study of Semantics, Types and Languages for Databases and Object-Oriented Programming", . October 1989. University of Pennsylvania Department of Computer and Information Science Technical Report No. MS-CIS-89-60. This paper is posted at ScholarlyCommons. https://repository.upenn.edu/cis_reports/852 For more information, please contact [email protected]. A Study of Semantics, Types and Languages for Databases and Object-Oriented Programming Abstract The purpose of this thesis is to investigate a type system for databases and object-oriented programming and to design a statically typed programming language for these applications. Such a language should ideally have a static type system that supports: polymorphism and static type inference, rich data structures and operations to represent various data models for databases including the relational model and more recent complex object models, central features of object-oriented programming including user definable class hierarchies, multiple inheritance, and data abstraction, the notion of extents and object-identities for object-oriented databases. Without a proper formalism, it is not obvious that the construction of such a type system is possible. This thesis attempts to construct one such formalism and proposes a programming language that uniformly integrate all of the above features. The specific contributions of this thesis include: A simple semantics for ML polymorphism and axiomatization of the equational theory of ML. A uniform generalization of the relational model to arbitrary complex database objects that are constructed by labeled records, labeled variants, finite sets and ecursivr e definition. A framework for semantics of types for complex database objects. The notion of conditional typing schemes that extends Milner's typing scheme for ML to a wide range of complex structures and operations. A formulation of the notion of classes and inheritance in an ML style static type system. The notion of views that enable us to represent object-oriented databases in an ML style static type system. A proposal of a polymorphic programming language, Machiavelli, for databases and object-oriented programming with static type inference. In addition to the above technical contributions, a prototype implementation of Machiavelli that embodies most of the features presented in this thesis has been done in Standard ML of New Jersey. Comments University of Pennsylvania Department of Computer and Information Science Technical Report No. MS- CIS-89-60. This technical report is available at ScholarlyCommons: https://repository.upenn.edu/cis_reports/852 A Study On Semantics, Types, and Languages For Databases and Object-Oriented Programming MS-CIS-89-60 LOGIC & COMPUTATION 15 At sushi 0hori Department of Computer and Information Science School of Engineering and Applied Science University of Pennsylvania Philadelphia, PA 19104 October 1989 ACKNOWLEDGMENTS: This research was supported in part by grants NSF IRI86-10617, ARO DAA6-29-84-K-0061, ONR N0001488-K-0634 and OK1 Electric Industry Co., Japan A STUDY OF SEMANTICS , TYPES AND LANGUAGES FOR DATABASES AND OB JECT-ORIENTED PROGRAMMING ATSUSHI OHORI A DISSERTATION in Computer and Information Science Presented to the Faculties of the University of Pennsylvania in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy. 1969 Peter Buneman Val Breazu-Tannen Co-supervisor of Dissertation Co-supervisor of Dissertation Jean Gallier ..- .,., . Graduate Group Chairpers~q . - r * I .vs @ COPYRIGHT ATSUSHI OHORI 1989 A STUDY OF SEMANTICS, TYPES AND LANGUAGES FOR DATABASES AND OBJECT-ORIENTED PROGRAMMING ATSUSHI OHORI CO-SUPERVISORS : PETER BUNEMAN AND VAL BREAZU-TANNEN The purpose of this thesis is to investigate a type system for databases and object-oriented programming and to design a statically typed programming language for these applications. Such a language should ideally have a static type system that supports: polymorphism and static type inference, rich data structures and operations to represent various data models for databases including the relational model and more recent complex object models, central features of object-oriented programming including user definable class hierarchies, multiple inheritance, and data abstraction, the notion of extents and object-identities for object-oriented databases. Without a proper formalism, it is not obvious that the construction of such a type system is possible. This thesis attempts to construct one such formalism and proposes a programming language that uniformly integrate all of the above features. The specific contributions of this thesis include: A simple semantics for hlL polymorphism and axiomatization of the equational theory of ML. A uniform generalization of the relational model to arbitrary complex database objects that are constructed by labeled records, labeled variants, finite sets and recursive definition. A framework for semantics of types for complex database objects. The notion of conditional typing schemes that extends Milner's typing scheme for hlL to a wide range of complex structures and operations. A formulation of the notion of classes and inheritance in an ML style static type system. The notion of views that enable us to represent object-oriented databases in an ML style static type system. A proposal of a polymorphic programming language, Machiavelli, for databases and object- oriented programming with static type inference. In addition to the above technical contributions, a prototype implementation of Machiavelli that embodies most of the features presented in this thesis has been done in Standard ML of New Jersey. ACKNOWLEDGEMENTS - I am indebted to my co-adviser Peter Buneman. He originally introduced me the area of types and semantics for database programming languages and recommended me to undertake the doctoral study. Without his enthusiastic encouragement, this dissertation would have never existed. Special thanks are also to my co-adviser Val Breazu-Tannen for his guiding me the are of syntax and semantics of types for programming languages and for his encouragements. Moreover, their constructive criticism and our continuous discussion directly contribute to the work. I am grateful to my external commitee members Tomasz Imielinski and John Mitchell for very useful discussion at several opportune moments and many helpful comments. I am as grateful to the other members of my thesis committee. Jean Callier, Aravind Joshi, and Dale Miller for their interest in my work and their invaluable comments. Many thanks are also to Luca Cardelli, Carl Gunter, Richard Hull. David MacQueen, hiitchell Wand and Aaron Watters for very helpful discussions and suggestions. Moreover Mitchell \.%'and made several constructive criticism on the draft paper on which a part of chapter 5 is based. I am grateful to OK1 Electric Industry Co., Japan. They granted my leave of absence for the study at University of Pennsylvania and provided financial support. Among them, special thanks are to Kenji Tateoka, Eiji Nohara, and Toshiyuki Matsumoto who gave me assistance and support at critical moments. Finally my special gratitude goes to my wife Hiroko. Without her, the endevour of graduate study would have been arid and trying experience. Contents ... Abstract 111 Acknowledgements iv 1 Introduction 1 1.1 Motivations and Purposes ................................. 1 1.2 Organization of Thesis ................................... 4 2 Mathematical Preliminaries 8 2.1 Basic Notions and Notations ............................... 8 2.2 Labeled Trees ........................................ 10 2.2.1 Definitions and Basic Properties ......................... 10 2.2.2 Substitutions and Unifications on Trees ..................... 15 2.2.3 Regular Trees .................................... 16 3 Analysis of ML : its Syntax and Semantics 22 3.1 Introduction ......................................... 22 3.1.1 Milner's original semantics ............................ 24 3.1.2 Damas-Milner type inference system and Mitchell-Harper's analysis ..... 25 3.1.3 A simple framework for ML polymorphism ................... 29 3.2 The Language Core-ML .................................. 30 3.2.1 Raw terms. types and type-schemes ....................... 30 3.2.2 Typings. typing schemes and terms of Core-ML ................. 33 3.2.3 Type Inference Problem .............................. 35 3.2.4 Relation to Darnas-Milner System ........................38 3.2.5 Equational theoriesofCore.ML .......................... 43 3.3 Semantics of Core-ML ................................... 44 3.3.1 Explicitly-typed language TA and its semantics ................. 44 3.3.2 Relationship between TA and Core-ML ..................... 46 3.3.3 Semantics of Core-ML ............................... 49 3.4 Soundness and Completeness of Core-ML Theories ................... 50 3.5 Extensions of Core-ML ................................... 52 3.6 Full Abstraction of ML ................................... 57 4 Database Domains 6 0 4.1 Introduction ......................................... 60 4.1.1 Data Structures for Database Objects .....................