Refinement types and computational duality

One lesson learned painfully over the past twenty years is the perilous interaction of Curry-style typing with evaluation order and side-effects. This led eventually to the value restriction on polymorphism in ML, as well as, more recently, to similar artifacts in type systems for ML with intersection and union refinement types. For example, some of the traditional subtyping laws for unions and intersections are unsound in the presence of effects, while union-elimination requires an evaluation context restriction in addition to the value restriction on intersection-introduction. Our aim is to show that rather than being ad hoc artifacts, phenomena such as the value and evaluation context restrictions arise naturally in type systems for effectful languages, out of principles of duality. Beginning with a review of recent work on the Curry-Howard interpretation of focusing proofs as pattern-matching programs, we explain how to interpret intersection and union refinements on these programs, and how to logically derive the subtyping relationship via an identity coercion interpretation. The value restriction, etc., emerge out of this analysis. However, this abstract account does not immediately yield a decidable type system, essentially because the syntax is infinitary--both "infinitely wide" and "infinitely deep". We show how to mechanically construct a finitary syntax by applying two well-known PL techniques--pattern-compilation and defunctionalization--and conclude by giving this finitary syntax an algorithmic refinement type system. Parallel to the text, we describe an embedding in the dependently-typed functional language Agda, both for the sake of clarifying these ideas, and also because formalization was an important guide in developing them. As one example, the Agda encoding split very naturally into an intrinsic ("Church") view of well-typed programs, and an extrinsic ("Curry") view of refinement typing for those programs.

[1]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[2]  Frank Pfenning,et al.  Tridirectional typechecking , 2004, POPL.

[3]  Hugo Herbelin,et al.  The duality of computation , 2000, ICFP '00.

[4]  Frank Pfenning,et al.  Church and Curry: Combining Intrinsic and Extrinsic Typing , 2008 .

[5]  Frank Pfenning,et al.  Intersection types and computational effects , 2000, ICFP '00.

[6]  Benjamin C. Pierce,et al.  Regular expression types for XML , 2005, ACM Trans. Program. Lang. Syst..

[7]  John C. Reynolds,et al.  The Meaning of Types From Intrinsic to Extrinsic Semantics , 2000 .

[8]  Jean-Yves Girard Locus Solum: From the Rules of Logic to the Logic of Rules , 2001, CSL.

[9]  G. Mints,et al.  Finite investigations of transfinite derivations , 1978 .

[10]  Noam Zeilberger On the unity of duality , 2008, Ann. Pure Appl. Log..

[11]  P. Martin-Löf Hauptsatz for the Intuitionistic Theory of Iterated Inductive Definitions , 1971 .

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

[13]  Mariangiola Dezani-Ciancaglini,et al.  Intersection and Union Types: Syntax and Semantics , 1995, Inf. Comput..

[14]  Noam Zeilberger,et al.  Focusing and higher-order abstract syntax , 2008, POPL '08.

[15]  Paul Blain Levy,et al.  Typed Normal Form Bisimulation , 2007, CSL.

[16]  Wilfried Buchholz,et al.  Notation systems for infinitary derivations , 1991, Arch. Math. Log..

[17]  I. Lakatos PROOFS AND REFUTATIONS (I)*† , 1963, The British Journal for the Philosophy of Science.

[18]  Olivier Danvy,et al.  On Evaluation Contexts, Continuations, and the Rest of the Computation , 2004 .

[19]  James Brotherston,et al.  Complete Sequent Calculi for Induction and Infinite Descent , 2007, 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007).

[20]  JEAN-MARC ANDREOLI,et al.  Logic Programming with Focusing Proofs in Linear Logic , 1992, J. Log. Comput..

[21]  Jérôme Vouillon,et al.  Recursive polymorphic types and parametricity in an operational framework , 2005, 20th Annual IEEE Symposium on Logic in Computer Science (LICS' 05).

[22]  Frank Pfenning,et al.  Refinement types for ML , 1991, PLDI '91.

[23]  Peter Selinger,et al.  Control categories and duality: on the categorical semantics of the lambda-mu calculus , 2001, Mathematical Structures in Computer Science.

[24]  Mariangiola Dezani-Ciancaglini,et al.  A filter lambda model and the completeness of type assignment , 1983, Journal of Symbolic Logic.

[25]  Andrew K. Wright Simple imperative polymorphism , 1995, LISP Symb. Comput..

[26]  Jérôme Vouillon Polymorphic regular tree types and patterns , 2006, POPL '06.