Functional programming with names and necessity

All programs interact with their environments in one way or another: they read and write to memory, query users for input, print out results, send data to remote servers, etc. Because increasingly complex environments result in increasingly difficult and error-prone programming, programming languages should facilitate compile-time detection of erroneous interactions with environments. In this dissertation, I propose variants of modal logic with names, and their related λ-calculi, as a type theoretic foundation for such languages. In the first part of the dissertation, I review the judgmental formulation of propositional constructive modal logic, and the definitions of necessity and possibility as universal and existential quantification over possible worlds. In the application to functional programming, possible worlds in modal logic will correspond to execution environments. The second part investigates the notions of partial judgments; that is, possibility correspond to bounded universal and bounded existential quantification over possible worlds. While the partiality condition may be specified in several different ways, in this dissertation the focus is on the definition of partiality in terms of names. Names are labels for propositions, and a set of names represents the partiality condition obtained as a conjunction of the respective propositions. In the third part, I discuss applications of modal logic to staged computation and metaprogramming. In these applications, it is frequently necessary to consider a primitive operation of capture-incurring substitution of program expressions into a context, which is naturally expressed in a modal type system. The last part of the dissertation develops modal type systems for effects. The effects associated with partial possibility are those that permanently change the execution environments, and therefore must be executed in a specific linear order. Writing into a memory location is a typical example. The effects associated with partial necessity are those that may depend on the execution environment, but do not change it—they are benign, and do not need to be specifically serialized. Examples include memory reads and control flow effects.

[1]  Yoshihiko Futamura,et al.  Partial Evaluation of Computation Process--An Approach to a Compiler-Compiler , 1999, High. Order Symb. Comput..

[2]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[3]  Simon L. Peyton Jones,et al.  A semantics for imprecise exceptions , 1999, PLDI '99.

[4]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[5]  Philip Wadler,et al.  The marriage of effects and monads , 1998, ICFP '98.

[6]  Frank Pfenning,et al.  A modal foundation for meta-variables , 2003, MERLIN '03.

[7]  Simon L. Peyton Jones,et al.  State in Haskell , 1995, LISP Symb. Comput..

[8]  Martin Odersky,et al.  A functional theory of local names , 1994, POPL '94.

[9]  D. Prawitz Natural Deduction: A Proof-Theoretical Study , 1965 .

[10]  Frank Pfenning,et al.  Higher-order abstract syntax , 1988, PLDI '88.

[11]  Philip Wadler,et al.  Monads for functional programming , 1995, NATO ASI PDC.

[12]  Andrzej Filinski,et al.  Representing monads , 1994, POPL '94.

[13]  Daniel P. Friedman,et al.  Enriching the lambda calculus with contexts: toward a theory of incremental program construction , 1996, ICFP '96.

[14]  John C. Reynolds,et al.  Definitional Interpreters for Higher-Order Programming Languages , 1972, ACM '72.

[15]  Peter Lee,et al.  Run-time code generation and modal-ML , 1998, PLDI.

[16]  S. Brookes,et al.  Applications of Categories in Computer Science: Computational comonads and intensional semantics , 1992 .

[17]  Atsushi Ohori,et al.  A typed context calculus , 2001, Theor. Comput. Sci..

[18]  Walid Taha,et al.  An Idealized MetaML: Simpler, and More Expressive , 1999, ESOP.

[19]  Matthias Felleisen,et al.  Reasoning with Continuations , 1986, LICS.

[20]  Andrzej Filinski,et al.  Representing layered monads , 1999, POPL '99.

[21]  Robert Glück,et al.  An Automatic Program Generator for Multi-Level Specialization , 1997, LISP Symb. Comput..

[22]  Olivier Danvy,et al.  A Functional Abstraction of Typed Contexts , 1989 .

[23]  D. Scott Identity and existence in intuitionistic logic , 1979 .

[24]  Tim Sheard,et al.  Closed types for a safe imperative MetaML , 2003, J. Funct. Program..

[25]  Pierre Jouvelot,et al.  Reasoning about continuations with control effects , 1989, PLDI '89.

[26]  Joe B. Wells,et al.  Typability and Type Checking in System F are Equivalent and Undecidable , 1999, Ann. Pure Appl. Log..

[27]  Yukiyoshi Kameyama,et al.  A Simply Typed Context Calculus with First-class Environments , 2001, J. Funct. Log. Program..

[28]  Didier Rémy,et al.  A generalization of exceptions and control in ML-like languages , 1995, FPCA '95.

[29]  Philippe de Groote,et al.  A Simple Calculus of Exception Handling , 1995, TLCA.

[30]  Hiroshi Nakano A constructive formalization of the catch and throw mechanism , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[31]  Peter Lee,et al.  Optimizing ML with run-time code generation , 1996, PLDI '96.

[32]  Eugenio Moggi,et al.  Computational lambda-calculus and monads , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[33]  Pierre Jouvelot,et al.  Algebraic reconstruction of types and effects , 1991, POPL '91.

[34]  Mads Tofte,et al.  Region-based Memory Management , 1997, Inf. Comput..

[35]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[36]  Walid Taha,et al.  A Sound Reduction Semantics for Untyped CBN Multi-stage Computation. Or, the Theory of MetaML is Non-trivial (Extended Abstract) , 1999, PEPM.

[37]  Andrew M. Pitts,et al.  Nominal Logic: A First Order Theory of Names and Binding , 2001, TACS.

[38]  Martin Hofmann Semantical analysis of higher-order abstract syntax , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[39]  Matthias Felleisen,et al.  Reasoning with continuations II: full abstraction for models of control , 1990, LISP and Functional Programming.

[40]  Philip Wadler,et al.  Monads and composable continuations , 1994, LISP Symb. Comput..

[41]  Maria Simi,et al.  A Formalization of Viewpoints , 1995, Fundam. Informaticae.

[42]  Davide Ancona,et al.  A Fresh Calculus for Name Management , 2004, GPCE.

[43]  Frank Pfenning,et al.  On a modal lambda calculus for S4 , 1995, MFPS.

[44]  Gordon D. Plotkin,et al.  Abstract syntax and variable binding , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[45]  Andrei P. Ershov,et al.  On the Partial Computation Principle , 1977, Inf. Process. Lett..

[46]  Walid Taha,et al.  Closed Types as a Simple Approach to Safe Imperative Multi-stage Programming , 2000, ICALP.

[47]  Andrew M. Pitts,et al.  A New Approach to Abstract Syntax with Variable Binding , 2002, Formal Aspects of Computing.

[48]  Christoph Lüth,et al.  Composing monads using coproducts , 2002, ICFP '02.

[49]  Yukiyoshi Kameyama,et al.  Strong normalizability of the non-deterministic catch/throw calculi , 2002, Theor. Comput. Sci..

[50]  Michael Mendler,et al.  Propositional Lax Logic , 1997, Inf. Comput..

[51]  J. LandinP. Correspondence between ALGOL 60 and Church's Lambda-notation , 1965 .

[52]  Dana S. Scott,et al.  Advice on Modal Logic , 1970 .

[53]  Philip Wadler,et al.  Combining Monads , 1992 .

[54]  Robert Glück,et al.  Efficient Multi-level Generating Extensions for Program Specialization , 1995, PLILP.

[55]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[56]  Peter Sestoft,et al.  An experiment in partial evaluation: the generation of a compiler generator , 1985, SIGP.

[57]  Nikolaj Bjørner Type checking meta programs , 1999 .

[58]  Aleksandar Nanevski,et al.  From dynamic binding to state via modal possibility , 2003, PPDP '03.

[59]  Christopher Strachey,et al.  Continuations: A Mathematical Semantics for Handling Full Jumps , 2000, High. Order Symb. Comput..

[60]  Peter J. Stuckey,et al.  Exception analysis for non-strict languages , 2002, ICFP '02.

[61]  Andrew M. Pitts,et al.  FreshML: programming with binders made simple , 2003, ICFP '03.

[62]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.

[63]  Laurent Dami,et al.  Functional Programming with Dynamic Binding , 1996 .

[64]  Dale Miller,et al.  An Extension to ML to Handle Bound Variables in Data Structures: Preliminary Report , 1990 .

[65]  Matthias Felleisen,et al.  The theory and practice of first-class prompts , 1988, POPL '88.

[66]  Valeria de Paiva,et al.  On an Intuitionistic Modal Logic , 2000, Stud Logica.

[67]  Aleksandar Nanevski Meta-programming with names and necessity , 2002, ICFP '02.

[68]  Günter Asser,et al.  Zeitschrift für mathematische Logik und Grundlagen der Mathematik , 1955 .

[69]  Robert Harper,et al.  Typing first-class continuations in ML , 1991, POPL '91.

[70]  Pierre Jouvelot,et al.  The type and effect discipline , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[71]  Frank Pfenning,et al.  Primitive recursion for higher-order abstract syntax , 1997, Theor. Comput. Sci..

[72]  Robert Harper,et al.  Proof-directed debugging , 1999, Journal of Functional Programming.

[73]  Walid Taha,et al.  Environment classifiers , 2003, POPL '03.

[74]  Alex K. Simpson,et al.  The proof theory and semantics of intuitionistic modal logic , 1994 .

[75]  John Launchbury,et al.  Implicit parameters: dynamic scoping with static types , 2000, POPL '00.

[76]  Frank Pfenning,et al.  A modal analysis of staged computation , 1996, POPL '96.

[77]  Walid Taha,et al.  Environment classifiers , 2003, POPL.

[78]  Luc Moreau,et al.  A Syntactic Theory of Dynamic Binding , 1997, High. Order Symb. Comput..

[79]  Jean-Yves Girard,et al.  The System F of Variable Types, Fifteen Years Later , 1986, Theor. Comput. Sci..

[80]  Frank Pfenning,et al.  Staged computation with names and necessity , 2005, J. Funct. Program..

[81]  Gavin M. Bierman,et al.  Dynamic rebinding for marshalling and update, with destruct-time ? , 2003, ICFP '03.

[82]  Ian A. Mason Computing with Contexts , 1999, High. Order Symb. Comput..

[83]  Walid Taha,et al.  Multi-stage programming with explicit annotations , 1997 .

[84]  Alberto Pardo Towards Merging Recursion and Comonads , 2000 .

[85]  Marcelo P. Fiore,et al.  Semantic analysis of normalisation by evaluation for typed lambda calculus , 2002, PPDP '02.

[86]  Olivier Danvy,et al.  Abstracting control , 1990, LISP and Functional Programming.

[87]  Walid Taha,et al.  Multi-Stage Programming: Its Theory and Applications , 1999 .

[88]  J. Altham Naming and necessity. , 1981 .

[89]  Yukiyoshi Kameyama,et al.  A Type-Theoretic Study on Partial Continuations , 2000, IFIP TCS.

[90]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[91]  David K. Gifford,et al.  Polymorphic effect systems , 1988, POPL '88.

[92]  Andrew M. Pitts,et al.  Observable Properties of Higher Order Functions that Dynamically Create Local Names, or What's new? , 1993, MFCS.

[93]  Frank Pfenning,et al.  A judgmental reconstruction of modal logic , 2001, Mathematical Structures in Computer Science.

[94]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[95]  Helmut Schwichtenberg,et al.  Normalisation by Evaluation , 1998, Prospects for Hardware Foundations.

[96]  Natasha Alechina,et al.  Categorical and Kripke Semantics for Constructive S4 Modal Logic , 2001, CSL.

[97]  Valeria de Paiva Natural Deduction and Context as (Constructive) Modality , 2003, CONTEXT.

[98]  John McCarthy,et al.  Notes on Formalizing Context , 1993, IJCAI.

[99]  Lars Birkedal,et al.  A constraint-based region inference algorithm , 2001, Theor. Comput. Sci..

[100]  Olivier Danvy,et al.  Type-directed partial evaluation , 1995, POPL '96.

[101]  Andrzej Filinski Declarative Continuations and Categorical Duality , 1989 .

[102]  G. Boolos,et al.  Self-Reference and Modal Logic , 1985 .

[103]  Rod M. Burstall,et al.  Explicit Environments , 1999, Fundam. Informaticae.

[104]  Eugenio Moggi,et al.  A Calculus for Symbolic Names Management , 2004 .

[105]  Peter Lee,et al.  Modal types as staging specifications for run-time code generation , 1998, CSUR.

[106]  Satoshi Kobayashi,et al.  Monad as Modality , 1997, Theor. Comput. Sci..

[107]  Laurent Dami,et al.  A Lambda-Calculus for Dynamic Binding , 1998, Theor. Comput. Sci..

[108]  Aleksandar Nanevski A modal calculus for effect handling , 2003 .

[109]  Olivier Danvy,et al.  Representing Control: a Study of the CPS Transformation , 1992, Mathematical Structures in Computer Science.

[110]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[111]  Matthias Felleisen,et al.  Control delimiters and their hierarchies , 1990, LISP Symb. Comput..

[112]  F. Pfenning,et al.  On a Modal λ-Calculus for S41 1This work is supported by NSF Grant CCR-9303383 and the Advanced Research Projects Agency under ARPA Order No. 8313. , 1995 .

[113]  P. Martin-Löf On the meanings of the logical constants and the justi cations of the logical laws , 1996 .

[114]  D. Ancona,et al.  A Calculus for Symbolic Names Management , 2003 .

[115]  David K. Gifford,et al.  Integrating functional and imperative programming , 1986, LFP '86.

[116]  Nick Benton,et al.  Monads and Effects , 2000, APPSEM.

[117]  Richard L. Mendelsohn,et al.  First-Order Modal Logic , 1998 .

[118]  Andrew M. Pitts,et al.  A Metalanguage for Programming with Bound Names Modulo Renaming , 2000, MPC.

[119]  Guillermo E. Herrera Automating the meta theory of deductive systems , 2000 .

[120]  Aleksandar Nanevski A modal calculus for named control e-ects , 2004 .

[121]  Karl Crary,et al.  What is a recursive module? , 1999, PLDI '99.

[122]  Hayo Thielecke,et al.  Categorical Structure of Continuation Passing Style , 1997 .

[123]  Ulrich Berger,et al.  An inverse of the evaluation functional for typed lambda -calculus , 1991, [1991] Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science.

[124]  François Pessaux,et al.  Type-based analysis of uncaught exceptions , 2000, TOPL.

[125]  Timothy G. Griffin,et al.  A formulae-as-type notion of control , 1989, POPL '90.

[126]  Nick Benton,et al.  Computational types from a logical perspective , 1998, Journal of Functional Programming.