Modal Types for Mobile Code

Total Page:16

File Type:pdf, Size:1020Kb

Modal Types for Mobile Code Modal Types for Mobile Code Tom Murphy VII CMU-CS-08-126 May 13, 2008 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 Thesis Committee: Robert Harper, Co-Chair Karl Crary, Co-Chair Frank Pfenning Peter Sewell Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy. Copyright c 2008 Tom Murphy VII Keywords: modal logic, distributed computing, programming languages, web pro- gramming, compilers, types Abstract In this dissertation I argue that modal type systems provide an elegant and practical means for controlling local resources in spatially distributed computer programs. A distributed program is one that executes in multiple physical or logical places. It usually does so because those places have local resources that can only be used in those locations. Such resources can include processing power, proximity to data, hardware, or the physical presence of a user. Programmers that write distributed applications therefore need to be able to reason about the places in which their programs will execute. This work provides an elegant and practical way to think about such programs in the form of a type system derived from modal logic. Modal logic allows for reasoning about truth from multiple simultaneous perspectives. These perspectives, called “worlds,” are identified with the lo- cations in the distributed program. This enables the programming language to be simultaneously aware of the various hosts involved in a program, their local resources, and their differing perspectives on each other’s code and data. This leads to a clean and general type structure for programs that re- spects locality while permitting high-level language features. To argue that this system is elegant, I present a modal logic formulated for this purpose and then prove its global soundness and completeness and its equivalence to known logics. I then show how a small programming lan- guage can be derived from the logic, and how it can be implemented, prov- ing properties of this abstract compilation procedure. All of these theorems are formalized in Twelf and can be checked by computer. To demonstrate that it is practical, I then extend the modal calculus to a full-fledged programming language based on ML. I implemented a com- piler for this language for the specific case of web applications, a distributed computation involving two hosts with widely different capabilities: the web server and the web browser. I then use the completed implementation to build realistic web applications. iv Contents 1 Introduction 1 1.1 Overview . .1 1.2 Organization . .4 2 Located programming 5 2.1 ConCert and Grid/ML . .5 2.2 Marshaling and location . .8 3 A modal logic for distributed computing 11 3.1 Modal logic . 11 3.1.1 Accessibility . 14 3.1.2 IS5[ ..................................... 15 3.2 Lambda 5 . 17 3.2.1 Action at a distance . 17 3.2.2 Lambda 5 natural deduction . 18 3.2.3 Soundness and completeness . 21 3.2.4 Equivalence to IS5[ ............................ 27 3.3 Dynamic semantics . 28 3.4 C5.......................................... 32 3.4.1 Classical control flow . 32 3.4.2 Classical natural deduction . 33 3.4.3 Classical sequent calculus . 35 3.4.4 Soundness and completeness . 37 3.4.5 Examples . 40 3.4.6 Operational semantics . 42 3.5 Validity . 50 3.5.1 Sequent calculus . 51 3.5.2 Operational semantics . 54 3.5.3 Type safety . 56 3.5.4 Relationship with other connectives . 58 3.6 Summary . 59 v 4 Modal typed compilation 61 4.1 The at modality . 61 4.2 MinML5 external language . 62 4.2.1 Addresses . 62 4.2.2 Syntax and static semantics . 63 4.2.3 Dynamic semantics . 65 4.3 MinML5 internal language . 65 4.3.1 Dynamic semantics . 68 4.4 Elaboration . 71 4.4.1 Elaboration in Twelf . 74 4.4.2 The elaboration relations . 78 4.5 Continuation passing style . 83 4.5.1 Dynamic semantics . 85 4.5.2 Type safety . 87 4.6 CPS conversion . 89 4.6.1 Static correctness . 90 4.6.2 CPS conversion in Twelf . 92 4.7 Closure conversion . 98 4.7.1 Closure conversion in Twelf . 103 4.8 Conclusion . 108 5 ML5 and its implementation 111 5.1 ML5 . 112 5.1.1 Hello, version! . 112 5.1.2 Type and validity inference . 115 5.1.3 Interacting with the environment . 116 5.1.4 ML-like features . 120 5.1.5 Summary . 125 5.2 ML5/pgh . 125 5.2.1 Design concerns . 125 5.3 Front-end . 128 5.3.1 Parsing . 128 5.3.2 The internal language . 130 5.3.3 Elaboration . 137 5.3.4 Optimization . 147 5.4 The CPS language . 147 5.4.1 Return to Oz . 154 5.4.2 CPS conversion . 160 5.4.3 Type-directed translations . 165 5.4.4 Optimizations . 169 5.4.5 Type representation . 170 5.4.6 Closure conversion . 173 5.4.7 Type representation II . 177 5.4.8 Hoisting . 179 vi 5.4.9 Code generation . 182 5.5 Runtime . 190 5.5.1 Server 5 . 190 5.5.2 Communication . 194 5.5.3 Client runtime . 195 5.5.4 Marshaling and unmarshaling . 197 5.6 Summary . 202 6 Applications 205 6.1 Watchkey . 205 6.2 Chat . 207 6.3 Wiki . 211 6.4 Spreadsheet . 214 6.5 Summary . 215 7 Conclusion 217 7.1 Related work . 217 7.1.1 Modal logic in distributed computing . 219 7.1.2 Distributed ML-like languages . 221 7.1.3 Languages for web applications . 222 7.2 Future work . 223 7.2.1 Modal type systems . 224 7.2.2 ML5 and its implementation . 225 7.2.3 Web programming . 229 7.2.4 Conclusion . 230 A Twelf proofs 233 A.1 Equivalence of Lambda 5 natural deduction and sequent calculus . 233 A.2 Equivalence of IS5[ natural deduction and sequent calculus . 241 A.3 Lambda 5 dynamic semantics . 244 A.3.1 The %partial extension . 244 A.3.2 Dynamic semantics . 244 A.4 Soundness and completeness of C5 . 246 A.5 Operational semantics and type safety of C5 . 257 A.5.1 Natural numbers . 258 A.5.2 Operational semantics . ..
Recommended publications
  • Functional Javascript
    www.it-ebooks.info www.it-ebooks.info Functional JavaScript Michael Fogus www.it-ebooks.info Functional JavaScript by Michael Fogus Copyright © 2013 Michael Fogus. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editor: Mary Treseler Indexer: Judith McConville Production Editor: Melanie Yarbrough Cover Designer: Karen Montgomery Copyeditor: Jasmine Kwityn Interior Designer: David Futato Proofreader: Jilly Gagnon Illustrator: Robert Romano May 2013: First Edition Revision History for the First Edition: 2013-05-24: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449360726 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Functional JavaScript, the image of an eider duck, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐ mark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
    [Show full text]
  • Combinatorial Species and Labelled Structures Brent Yorgey University of Pennsylvania, [email protected]
    University of Pennsylvania ScholarlyCommons Publicly Accessible Penn Dissertations 1-1-2014 Combinatorial Species and Labelled Structures Brent Yorgey University of Pennsylvania, [email protected] Follow this and additional works at: http://repository.upenn.edu/edissertations Part of the Computer Sciences Commons, and the Mathematics Commons Recommended Citation Yorgey, Brent, "Combinatorial Species and Labelled Structures" (2014). Publicly Accessible Penn Dissertations. 1512. http://repository.upenn.edu/edissertations/1512 This paper is posted at ScholarlyCommons. http://repository.upenn.edu/edissertations/1512 For more information, please contact [email protected]. Combinatorial Species and Labelled Structures Abstract The theory of combinatorial species was developed in the 1980s as part of the mathematical subfield of enumerative combinatorics, unifying and putting on a firmer theoretical basis a collection of techniques centered around generating functions. The theory of algebraic data types was developed, around the same time, in functional programming languages such as Hope and Miranda, and is still used today in languages such as Haskell, the ML family, and Scala. Despite their disparate origins, the two theories have striking similarities. In particular, both constitute algebraic frameworks in which to construct structures of interest. Though the similarity has not gone unnoticed, a link between combinatorial species and algebraic data types has never been systematically explored. This dissertation lays the theoretical groundwork for a precise—and, hopefully, useful—bridge bewteen the two theories. One of the key contributions is to port the theory of species from a classical, untyped set theory to a constructive type theory. This porting process is nontrivial, and involves fundamental issues related to equality and finiteness; the recently developed homotopy type theory is put to good use formalizing these issues in a satisfactory way.
    [Show full text]
  • Uusi Hakemisto
    214 6. Tunneling 215 ROCK EXCAVATION HANDBOOK 6.1. GENERAL SELECTING TUNNELING METHODS In modern tunnel and underground cavern excavation, it is possible to select from many dif- ferent methods. The following factors should be taken into consideration when selecting the method: - Tunnel dimensions - Tunnel geometry - Length of tunnel, total volume to be excavated - Geological and rock mechanical conditions - Ground water level and expected water inflow - Vibration restrictions FIGURE 6.1.-2. Range of methods compared to uniaxal compressive strength. - Allowed ground settlements The methods can be divided into drill & blast, and mechanical excavation. Mechanical meth- ods can be split further to partial face (e.g. roadheaders, hammers, excavators) or full face (TBM, shield, pipe jacking, micro tunneling). FIGURE 6.1.-1. Tunneling methods in different rock/soil conditions. The drill & blast method is still the most typical method for medium to hard rock conditions. It can be applied to a wide range of rock conditions. Some of its features include versatile equipment, fast start-up and relatively low capital cost tied to the equipment. On the other hand, the cyclic nature of the drill & blast method requires good work site organization. FIGURE 6.1.-3. Drill and blast cycle. Blast vibrations and noise also restrict the use of drill & blast in urban areas. 216 6. Tunneling 217 ROCK EXCAVATION HANDBOOK Hard-rock TBMs can be used in relatively soft to hard rock conditions, and best when rock DRIFTING AND TUNNELING fracturing & weakness zones are predictable. The TBM is most economical method for longer tunnel lengths, in which its high investment cost and timely build-up can be utilized by the Many mines and excavation sites still plan their drilling patterns manually, but advanced high advance rate of excavation.
    [Show full text]
  • View on 5G Architecture
    5G PPP Architecture Working Group View on 5G Architecture Version 3.0, June 2019 Date: 2019-06-19 Version: 3.0 Dissemination level: Public Consultation Abstract The 5G Architecture Working Group as part of the 5G PPP Initiative is looking at capturing novel trends and key technological enablers for the realization of the 5G architecture. It also targets at presenting in a harmonized way the architectural concepts developed in various projects and initiatives (not limited to 5G PPP projects only) so as to provide a consolidated view on the technical directions for the architecture design in the 5G era. The first version of the white paper was released in July 2016, which captured novel trends and key technological enablers for the realization of the 5G architecture vision along with harmonized architectural concepts from 5G PPP Phase 1 projects and initiatives. Capitalizing on the architectural vision and framework set by the first version of the white paper, the Version 2.0 of the white paper was released in January 2018 and presented the latest findings and analyses of 5G PPP Phase I projects along with the concept evaluations. The work has continued with the 5G PPP Phase II and Phase III projects with special focus on understanding the requirements from vertical industries involved in the projects and then driving the required enhancements of the 5G Architecture able to meet their requirements. The results of the Working Group are now captured in this Version 3.0, which presents the consolidated European view on the architecture design. Dissemination level: Public Consultation Table of Contents 1 Introduction........................................................................................................................
    [Show full text]
  • Httpclient-Tutorial.Pdf
    HttpClient Tutorial Oleg Kalnichevski Jonathan Moore Jilles van Gurp Preface .................................................................................................................................... iv 1. HttpClient scope .......................................................................................................... iv 2. What HttpClient is NOT .............................................................................................. iv 1. Fundamentals ....................................................................................................................... 1 1.1. Request execution ...................................................................................................... 1 1.1.1. HTTP request .................................................................................................. 1 1.1.2. HTTP response ............................................................................................... 2 1.1.3. Working with message headers ........................................................................ 2 1.1.4. HTTP entity .................................................................................................... 3 1.1.5. Ensuring release of low level resources ............................................................ 5 1.1.6. Consuming entity content ................................................................................ 6 1.1.7. Producing entity content .................................................................................. 6 1.1.8. Response
    [Show full text]
  • Tunnel Operations, Maintenance, Inspection, and Evaluation (TOMIE
    Tunnel Operations, Maintenance, Inspection, and Evaluation (TOMIE) Manual July 2015 Publication No. FHWA-HIF-15-005 Tunnel Operations, Maintenance, Inspection, and Evaluation Manual July 2015 Publication No. FHWA-HIF-15-005 Federal Highway Administration Office of Bridges and Structures 1200 New Jersey Avenue, SE Washington DC 20590 1. Report No. 2. Government Accession No. 3. Recipient’s Catalog No. FHWA-HIF-15-005 4. Title and Subtitle 5. Report Date Tunnel Operations, Maintenance, Inspection, and Evaluation July 2015 6. Performing Organization Code (TOMIE) Manual 7. Author(s) 8. Performing Organization Report No. William Bergeson, PE and Steve Ernst, PE (FHWA) 9. Performing Organization Name and Address 10. Work Unit No. Federal Highway Administration 1200 New Jersey Ave, SE 11. Contract or Grant No. Washington, D.C. 20590 12. Sponsoring Agency Name and Address 13. Type of Report and Period Covered 14. Sponsoring Agency Code 15. Supplementary Notes The FHWA would like to acknowledge the contribution of HDR on a draft version of this Manual under Contract DTFH61-07-D-00004. The authors of the draft manual were Brian J. Leshko, P.E. (HDR), Chester L. Allen, P.E. (GF), Mark J. Pavlick, P.E. (HDR). HDR Engineering, Inc. 11 Stanwix Street, Suite 800 Pittsburgh, Pennsylvania 15222 Brian Kozy, PE, PhD and Lubin Gao, PE, PhD (FHWA) provided expert review comments. Gail Edwards (FHWA) provided technical edits. Michelle Cribbs (FHWA) checked this document for Section 508 compliance. 16. Abstract Tunnels represent a significant financial investment with challenging design, construction, and operational issues. Tunnels that are not adequately maintained usually require more costly and extensive repairs.
    [Show full text]
  • Tutorial: Security Patterns and Secure Systems Design Using UML
    Tutorial: Security patterns and secure systems design using UML Eduardo B. Fernandez and Maria M. Larrondo Petrie Dept. of Computer Science and Eng. Florida Atlantic University www.cse.fau.edu/~security ICWMC/ICCGI 2007 {ed, maria}@cse.fau.edu 1 Guadaloupe, French Caribbean, IARIA, 4-9 March 2007 • Professor of Computer Science at Florida Atlantic University, Boca Raton, FL, USA • At IBM for 8 years (L.A. Scientific Center). • Wrote the first book on database security (Addison-Wesley, 1981). • Author of many research papers • Consultant to IBM, Siemens, Lucent,… • MS EE Purdue U, PhD CS UCLA ICWMC/ICCGI 2007 2 Guadaloupe, French Caribbean, IARIA, 4-9 March 2007 • Professor of Computer Science & Engineering and Associate Dean of Academic & International Affairs at Florida Atlantic University, Boca Raton, FL., USA • Executive Vice President of LACCEI (Latin American and Caribbean Consortium of Engineering Institutions) • Authored over 130 research papers on complex systems modeling (environmental, security) • Over US$2.5M in research grants from NATO, IBM, NSF, and South Florida Water Management District ICWMC/ICCGI 2007 3 Guadaloupe, French Caribbean, IARIA, 4-9 March 2007 Abstract • Analysis and design patterns are well established to build high-quality object- oriented software. Patterns combine experience and good practices to develop basic models that can be used for new designs. Security patterns join the extensive knowledge accumulated about security with the structure provided by patterns to provide guidelines for secure system design and evaluation. We show a variety of security patterns and their use in the construction of secure systems. These patterns include Authentication, Authorization, Role-based Access Control, Firewalls, Web Services Security, and others.
    [Show full text]
  • Composing Software an Exploration of Functional Programming and Object Composition in Javascript
    Composing Software An Exploration of Functional Programming and Object Composition in JavaScript Eric Elliott This book is for sale at http://leanpub.com/composingsoftware This version was published on 2019-02-24 This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do. © 2017 - 2019 Eric Elliott Contents Thank You ................................................... 1 Composing Software: An Introduction ................................. 2 You Compose Software Every Day .................................. 3 Conclusion ................................................. 10 The Dao of Immutability (The Way of the Functional Programmer) .............. 11 Forward .................................................. 11 The Rise and Fall and Rise of Functional Programming (Composable Software) ....... 13 The Rise of Functional Programming ................................. 13 The Fall of Functional Programming ................................. 16 The Rise of Functional Programming ................................. 16 Functional Programming Has Always Been Alive and Well ................... 17 Why Learn Functional Programming in JavaScript? ........................ 18 Pure Functions ................................................ 25 What is a Function? ........................................... 25 Mapping .................................................
    [Show full text]
  • Amity School of Engineering & Technology Amity
    Amity School of Engineering & Technology Amity University Object Oriented System Design Code: CSE416 Prepared By Hari Mohan Pandey Assistant Professor, CSE Department [email protected] Module Notes Department of Computer Science & Engineering ODD Semester 2014 Object Oriented System Design Page: 1/74 UNIT-3 DIAGRAMS 3.1 Sequence diagrams A sequence diagram is an interaction diagram that details how operations are carried out - - what messages are sent and when. Sequence diagrams are organized according to time. The time progresses as you go down the page. The objects involved in the operation are listed from left to right according to when they take part in the message sequence. Below is a sequence diagram for making a hotel reservation. The object initiating the sequence of messages is a Reservation window. Figure: Sequence Diagram-1 Object Oriented System Design Page: 2/74 The Reservation window sends a makeReservation () message to a HotelChain. The HotelChain then sends a makeReservation () message to a Hotel. If the Hotel has available rooms, then it makes a Reservation and a Confirmation. Within a sequence diagram, on object is available in the box at the top of a dotted vertical line. Each vertical dotted line is a lifeline, representing the time that an object exists. Each arrow is a message call. An arrow goes from the sender to the top of the activation bar of the message on the receiver's lifeline. The activation bar represents the duration of execution of the message. Each message is labeled at minimum with the message name. In our diagram, the Hotel issues a self call to determine if a room is available.
    [Show full text]
  • Creating High-Performance, Statically Type-Safe Network Applications
    UCAM-CL-TR-775 Technical Report ISSN 1476-2986 Number 775 Computer Laboratory Creating high-performance, statically type-safe network applications Anil Madhavapeddy March 2010 15 JJ Thomson Avenue Cambridge CB3 0FD United Kingdom phone +44 1223 763500 http://www.cl.cam.ac.uk/ c 2010 Anil Madhavapeddy This technical report is based on a dissertation submitted April 2006 by the author for the degree of Doctor of Philosophy to the University of Cambridge, Robinson College. Technical reports published by the University of Cambridge Computer Laboratory are freely available via the Internet: http://www.cl.cam.ac.uk/techreports/ ISSN 1476-2986 Abstract A typical Internet server finds itself in the middle of a virtual battleground, under constant threat from worms, viruses and other malware seeking to subvert the original intentions of the programmer. In particular, critical Internet servers such as OpenSSH, BIND and Sendmail have had numerous security issues ranging from low-level buffer overflows to subtle protocol logic errors. These problems have cost billions of dollars as the growth of the Internet exposes increasing numbers of computers to electronic malware. Despite the decades of research on techniques such as model-checking, type-safety and other forms of formal analysis, the vast majority of server implementations continue to be written unsafely and informally in C/C++. In this dissertation we propose an architecture for constructing new implementations of stan- dard Internet protocols which integrates mature formal methods not currently used in deployed servers: (i) static type systems from the ML family of functional languages; (ii) model checking to verify safety properties exhaustively about aspects of the servers; and (iii) generative meta- programming to express high-level constraints for the domain-specific tasks of packet parsing and constructing non-deterministic state machines.
    [Show full text]
  • Architecture Styles and Design of Network Based Software
    UNIVERSITY OF CALIFORNIA, IRVINE Architectural Styles and the Design of Network-based Software Architectures DISSERTATION submitted in partial satisfaction of the requirements for the degree of DOCTOR OF PHILOSOPHY in Information and Computer Science by Roy Thomas Fielding Dissertation Committee: Professor Richard N. Taylor, Chair Professor Mark S. Ackerman Professor David S. Rosenblum 2000 © Roy Thomas Fielding, 2000. All rights reserved. The dissertation of Roy Thomas Fielding is approved and is acceptable in quality and form for publication on microfilm: ____________________________________ ____________________________________ ____________________________________ Committee Chair University of California, Irvine 2000 ii DEDICATION To my parents, Pete and Kathleen Fielding, who made all of this possible, for their endless encouragement and patience. And also to Tim Berners-Lee, for making the World Wide Web an open, collaborative project. What is life? It is the flash of a firefly in the night. It is the breath of a buffalo in the wintertime. It is the little shadow which runs across the grass and loses itself in the sunset. — Crowfoot's last words (1890), Blackfoot warrior and orator. Almost everybody feels at peace with nature: listening to the ocean waves against the shore, by a still lake, in a field of grass, on a windblown heath. One day, when we have learned the timeless way again, we shall feel the same about our towns, and we shall feel as much at peace in them, as we do today walking by the ocean, or stretched out in the long
    [Show full text]
  • Protocols and Standards for Simulation and Co-Simulation Doctoral Thesis Doctoral for Demanding Maritime Operations
    Doctoral theses at NTNU, 2021:81 Lars Ivar Hatledal Lars Ivar Hatledal Protocols and Standards for Simulation and Co-simulation Doctoral thesis Doctoral For Demanding Maritime Operations ISBN 978-82-326-5777-3 (printed ver.) ISBN 978-82-326-5231-0 (electronic ver.) ISSN 1503-8181 (printed ver.) ISSN 2703-8084 (online ver.) Doctoral theses at NTNU, 2021:81 theses at NTNU, Doctoral NTNU Engineering Philosophiae Doctor Faculty of Engineering Thesis for the Degree of Thesis for the Degree Department of Ocean Operations and Civil Department of Ocean Operations Norwegian University of Science and Technology Lars Ivar Hatledal Protocols and Standards for Simulation and Co-simulation For Demanding Maritime Operations Thesis for the Degree of Philosophiae Doctor Trondheim, March 2021 Norwegian University of Science and Technology Faculty of Engineering Department of Ocean Operations and Civil Engineering NTNU Norwegian University of Science and Technology Thesis for the Degree of Philosophiae Doctor Faculty of Engineering Department of Ocean Operations and Civil Engineering © Lars Ivar Hatledal ISBN 978-82-326-5777-3 (printed ver.) ISBN 978-82-326-5231-0 (electronic ver.) ISSN 1503-8181 (printed ver.) ISSN 2703-8084 (online ver.) Doctoral theses at NTNU, 2021:81 Printed by NTNU Grafisk senter Abstract There is a strong demand for innovation and efficiency within operations, life cycle services, and design of maritime systems. Modern vessels operate increasingly autonomously through strongly interacting sub-systems. These systems are dedicated to a specific, primary objective of the vessel or may be part of the general essential ship operations. The sub-systems exchange data and make coordinated operational decisions, ideally without any user interaction.
    [Show full text]