Linear/Non-Linear Types for Embedded Domain-Specific Languages

Linear/Non-Linear Types for Embedded Domain-Specific Languages

University of Pennsylvania ScholarlyCommons Publicly Accessible Penn Dissertations 2018 Linear/non-Linear Types For Embedded Domain-Specific Languages Jennifer Paykin University of Pennsylvania, [email protected] Follow this and additional works at: https://repository.upenn.edu/edissertations Part of the Computer Sciences Commons Recommended Citation Paykin, Jennifer, "Linear/non-Linear Types For Embedded Domain-Specific Languages" (2018). Publicly Accessible Penn Dissertations. 2752. https://repository.upenn.edu/edissertations/2752 This paper is posted at ScholarlyCommons. https://repository.upenn.edu/edissertations/2752 For more information, please contact [email protected]. Linear/non-Linear Types For Embedded Domain-Specific Languages Abstract Domain-specific languages are often embedded inside of general-purpose host languages so that the embedded language can take advantage of host-language data structures, libraries, and tools. However, when the domain-specific language uses linear types, existing techniques for embedded languages fall short. Linear type systems, which have applications in a wide variety of programming domains including mutable state, I/O, concurrency, and quantum computing, can manipulate embedded non-linear data via the linear type !σ. However, prior work has not been able to produce linear embedded languages that have full and easy access to host-language data, libraries, and tools. This dissertation proposes a new perspective on linear, embedded, domain-specific languages derived from the linear/non-linear (LNL) interpretation of linear logic. The LNL model consists of two distinct fragments---one with linear types and another with non-linear types---and provides a simple categorical interface between the two. This dissertation identifies the linear fragment with the linear embedded language and the non-linear fragment with the general-purpose host language. The effectiveness of this framework is illustrated via a number of examples, implemented in a variety of host languages. In Haskell, linear domain-specific languages using mutable state and concurrency can take advantage of the monad that arises from the LNL model. In Coq, the QWIRE quantum circuit language uses linearity to enforce the no-cloning axiom of quantum mechanics. In homotopy type theory, quantum transformations can be encoded as higher inductive types to simplify the presentation of a quantum equational theory. These examples serve as case studies that prove linear/non-linear type theory is a natural and expressive interface in which to embed linear domain-specific languages. Degree Type Dissertation Degree Name Doctor of Philosophy (PhD) Graduate Group Computer and Information Science First Advisor Steve Zdancewic Keywords Domain-specific language, Linearity, Quantum computing, Type system Subject Categories Computer Sciences This dissertation is available at ScholarlyCommons: https://repository.upenn.edu/edissertations/2752 LINEAR/NON-LINEAR TYPES FOR EMBEDDED DOMAIN-SPECIFIC LANGUAGES Jennifer Paykin 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 2018 Supervisor of Dissertation Steve Zdancewic Professor of Computer and Information Science Graduate Group Chairperson Lyle Ungar Professor of Computer and Information Science Dissertation Committee Stephanie Weirich, Professor of Computer and Information Science, University of Pennsylvania Benjamin Pierce, Professor of Computer and Information Science, University of Pennsylvania Andre Scedrov, Professor of Mathematics, University of Pennsylvania Peter Selinger, Professor of Mathematics, Dalhousie University LINEAR/NON-LINEAR TYPES FOR EMBEDDED DOMAIN-SPECIFIC LANGUAGES COPYRIGHT 2018 Jennifer Paykin This work is licensed under a Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons:org/licenses/by/4:0/ Acknowledgment I have so many people to thank for helping me along the journey of this PhD. I could not have done it without the love and support of my partner and best friend, Jake, who was there for me every single step of the way. I also need to thank my parents Laurie and Lanny for giving me so many opportunities in my life, and my siblings Susan and Adam for helping me grow. I owe so much thanks to advisor Steve Zdancewic, who has been an amazing advisor and who has made me into the researcher I am today. Steve, thank you for teaching me new things, encouraging me to succeed, listening to my ideas, and waiting patiently until I realized you were right all along. I have been lucky to have many excellent mentors over the years. Thank you to Norman Danner, for introducing me to programming languages and pushing me to take advantage of the opportunities that come my way. Thank you to Stephanie Weirich, for inspiring me and supporting me over the years. Thank you to Benjamin Pierce, for making me into a better writer, speaker, and researcher. Thank you to the rest of my thesis committee|Peter Selinger and Andre Scedrov|for your feedback and encouragement. Finally, thank you to Neel Krishnaswami, Dan Licata, Val Tannen, and all my other collaborators, professors, and mentors for teaching me so much over the years. My time at Penn would have been much less enjoyable without the wonderful friends I have made here. To everyone at PLClub, Monday night quizzo, cisters, and GETUP, thank you for your friendship, your commiseration, and your support. So many people have made my life better at Penn that I cannot possibly list them all, but I need to single out my closest confidants and conspirators|Antal, Leo, Robert, and Kenny. Thanks for everything! Finally, my work has been supported financially by the following sources, whose contri- butions have been much appreciated: the NSF Graduate Research Fellowship Grant Number DGE-1321851; NSF Grant Number CCF-1421193; and ONR MURI No. FA9550-16-1-0082. iii ABSTRACT LINEAR/NON-LINEAR TYPES FOR EMBEDDED DOMAIN-SPECIFIC LANGUAGES Jennifer Paykin Steve Zdancewic Domain-specific languages are often embedded inside of general-purpose host languages so that the embedded language can take advantage of host-language data structures, li- braries, and tools. However, when the domain-specific language uses linear types, existing techniques for embedded languages fall short. Linear type systems, which have applica- tions in a wide variety of programming domains including mutable state, I/O, concurrency, and quantum computing, can manipulate embedded non-linear data via the linear type !σ. However, prior work has not been able to produce linear embedded languages that have full and easy access to host-language data, libraries, and tools. This dissertation proposes a new perspective on linear, embedded, domain-specific lan- guages derived from the linear/non-linear (LNL) interpretation of linear logic. The LNL model consists of two distinct fragments|one with linear types and another with non-linear types|and provides a simple categorical interface between the two. This dissertation iden- tifies the linear fragment with the linear embedded language and the non-linear fragment with the general-purpose host language. The effectiveness of this framework is illustrated via a number of examples, implemented in a variety of host languages. In Haskell, linear domain-specific languages using mutable state and concurrency can take advantage of the monad that arises from the LNL model. In Coq, the Qwire quantum circuit language uses linearity to enforce the no-cloning axiom of quantum mechanics. In homotopy type theory, quantum transformations can be encoded as higher inductive types to simplify the presentation of a quantum equational theory. These examples serve as case studies that prove linear/non-linear type theory is a natural and expressive interface in which to embed linear domain-specific languages. iv TABLE OF CONTENTS ACKNOWLEDGMENT ................................... iii ABSTRACT ........................................... iv 1 Introduction ......................................... 1 1.1 Conventions . 9 2 Linear type systems ................................... 10 2.1 A simple linear type system . 11 2.2 Linear connectives . 13 2.3 The exponential modality ! . 18 2.4 Dual Intuitionistic Linear Logic . 21 2.5 Indexed modalities . 23 2.6 Kind-based linear logic . 27 2.7 Linear/non-linear logic . 30 3 Embedded linear/non-linear types .......................... 36 3.1 A linear embedded language . 36 3.2 The linear/non-linear interface . 39 3.3 Example: linear file handles . 41 3.4 Monadic programming . 42 3.5 Extensions . 47 3.6 Example: session types . 50 3.7 Discussion . 54 4 Haskell Implementation ................................. 56 4.1 Dependent types in Haskell . 58 v 4.2 Linear types and type checking . 60 4.3 Running linear programs . 69 4.4 Monadic programming . 78 4.5 Example: Arrays . 82 4.6 Example: Session types . 87 4.7 Discussion and Related Work . 92 5 Embedded categorical semantics ........................... 98 5.1 Background . 98 5.2 Categories for multiplicative additive linear logic . 103 5.3 Linear/non-linear categories . 105 5.4 Embedded meta-theory . 106 5.5 Conclusion . 110 Case study: Quantum Computing 112 6 A quantum/non-quantum type system ....................... 113 6.1 Quantum computing background . 117 6.2 The quantum/non-quantum (QNQ) calculus . 122 6.3 Examples . 126 6.4 Denotational semantics . 130 7 Quantum equational theories

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    209 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