Papers by Giuseppe Castagna

Information and Computation, 2005
The Seal Calculus is a process language for describing mobile computation. Threads and resources ... more The Seal Calculus is a process language for describing mobile computation. Threads and resources are tree structured; the nodes thereof correspond to agents, the units of mobility. The Calculus extends a π-calculus core with synchronous, objective mobility of agents over channels. This paper systematically compares all previous variants of Seal Calculus. We study their operational behaviour with labelled transition systems and bisimulations; by comparing the resulting algebraic theorieswe highlight the differences between these apparently similar approaches. This leads us to identify the dialect of Seal that is most amenable to operational reasoning and can form the basis of a distributed programming language. We propose type systems for characterising the communications in which an agent can engage. The type systems thus enforce a discipline of agent mobility, since the latter is coded in terms of higher-order communication.

Logical Method in Computer Science, 2021
Twenty years ago, in an article titled "Covariance and contravariance: conflict without a cause",... more Twenty years ago, in an article titled "Covariance and contravariance: conflict without a cause", I argued that covariant and contravariant specialization of method parameters in object-oriented programming had different purposes and deduced that, not only they could, but actually they should both coexist in the same language. In this work I reexamine the result of that article in the light of recent advances in (sub-)typing theory and programming languages, taking a fresh look at this old issue. Actually, the revamping of this problem is just an excuse for writing an essay that aims at explaining sophisticated type-theoretic concepts, in simple terms and by examples, to undergraduate computer science students and/or willing functional programmers. Finally, I took advantage of this opportunity to describe some undocumented advanced techniques of type-systems implementation that are known only to few insiders that dug in the code of some compilers: therefore, even expert language designers and implementers may find this work worth of reading. This is a corrected and enhanced version of the paper arXiv:1809.01427 published originally on Feb. 13, 2020. See Appendix B for differences in the versions.

In this essay I present the advantages and, I dare say, the beauty of programming in a language w... more In this essay I present the advantages and, I dare say, the beauty of programming in a language with set-theoretic types, that is, types that include union, intersection, and negation type connectives. I show by several examples how settheoretic types are necessary to type some common programming patterns, but also how they play a key role in typing several language constructs-from branching and pattern matching to function overloading and type-cases-very precisely. I start by presenting the theory of types known as semantic subtyping and extend it to include polymorphic types. Next, I discuss the design of languages that use these types. I start by defining a theoretical framework that covers all the examples given in the first part of the presentation. Since the system of the framework cannot be effectively implemented, I then describe three effective restrictions of this system: (i) a polymorphic language with explicitly-typed functions, (ii) an implicitly typed polymorphic languageà la Hindley-Milner, and (iii) a monomorphic language that, by implementing classic union-elimination, precisely reconstructs intersection types for functions and implements a very general form of occurrence typing. I conclude the presentation with a short overview of other aspects of these languages, such as pattern matching, gradual typing, and denotational semantics.

In type-theoretic research on object-oriented programming, the issue of \covariance versus con-tr... more In type-theoretic research on object-oriented programming, the issue of \covariance versus con-travariance " is a topic of continuing debate. In this short note we argue that covariance and con-travariance appropriately characterize two distinct and independent mechanisms. The so-called contravariance rule correctly captures the subtyping relation (that relationwhich establisheswhich sets of functions can replace another given set in every context). A covariant relation, instead, characterizes the specialization of code (i.e., the denition of new code which replaces old def-initions in some particular cases). Therefore, covariance and contravariance are not opposing views, but distinct concepts that each have their place in object-oriented systems. Both can (and should) be integrated in a type-safe manner in object-oriented languages. We also show that the independence of the two mechanisms is not characteristic of a particular model but is valid in general, since covariant spe...
Giving types to binary methods causes signi cant problems for object-oriented language designers ... more Giving types to binary methods causes signi cant problems for object-oriented language designers and programmers. This paper o ers a comprehensive description of the problems arising from typing binary methods, and collects and contrasts diverse views and solutions. It summarizes the current debate on the problem of binary methods for a wide audience.
Proceedings of the ACM on Programming Languages
We define a new, more semantic interpretation of gradual types and use it to ``gradualize'... more We define a new, more semantic interpretation of gradual types and use it to ``gradualize'' two forms of polymorphism: subtyping polymorphism and implicit parametric polymorphism. In particular, we use the new interpretation to define three gradual type systems ---Hindley-Milner, with subtyping, and with union and intersection types--- in terms of two preorders, subtyping and materialization. We define these systems both declaratively ---by adding two subsumption-like rules--- which yields clearer, more intelligible, and streamlined definitions, and algorithmically by reusing existing techniques such as unification and tallying.

Proceedings of the ACM on Programming Languages
We propose a type system for functional languages with gradual types and set-theoretic type conne... more We propose a type system for functional languages with gradual types and set-theoretic type connectives and prove its soundness. In particular, we show how to lift the definition of the domain and result type of an application from non-gradual types to gradual ones and likewise for the subtyping relation. We also show that deciding subtyping for gradual types can be reduced in linear time to deciding subtyping on non-gradual types and that the same holds true for all subtyping-related decision problems that must be solved for type inference. More generally, this work not only enriches gradual type systems with unions and intersections and with the type precision that arise from their use, but also proposes and advocates a new style of gradual types programming where union and intersection types are used by programmers to instruct the system to perform fewer dynamic checks.
Planx, Nov 25, 2002
In this paper, we present the functional language Duce, discuss some design issues, and show its ... more In this paper, we present the functional language Duce, discuss some design issues, and show its adequacy for working with XML documents. Peculiar features of Duce are a powerful pattern matching, first class functions, overloaded functions, a very rich type system (arrows, sequences, pairs, records, intersections, unions, differences), precise type inference and a natural interpretation of types as sets of values. We also discuss how to add constructs for programming XML queries in a declarative (and, thus, optimizable) way and finally sketch a dispatch algorithm to demonstrate how static type information can be used in efficient compilation schemas.
this paper, simple records suffice. We do not give the definition of the encoding. Just remember ... more this paper, simple records suffice. We do not give the definition of the encoding. Just remember that all the terms and types written below are encodable in &.

L'objectif de cette these est de donner de nouveaux fondements fonctionnels a la programmatio... more L'objectif de cette these est de donner de nouveaux fondements fonctionnels a la programmation orientee objets, dans un cadre completement type. Les elements fondamentaux consideres sont la surcharge, le sous-typage et la liaison tardive. Un cadre formel est developpe afin de pouvoir etudier les langages objets fortement et statiquement types. Ainsi nous degageons un modele pour ces langages totalement orthogonal aux modeles par enregistrements. Dans ce modele il est possible d'interpreter, entre autres, le mecanisme de dispatch multiple et de changement de classe, l'extension et la redefinition des methodes d'une classe (sans modifier le type des objets), les messages en tant que valeurs de premiere classe et les classes partiellement abstraites. En outre ce modele explique les roles de la covariance et de la contravariance dans le sous-typage. Tout ceci est introduit de maniere formelle: nous commencons par definir une extension du lambda-calcul simplement type afin de modeliser la surcharge, le sous-typage et la liaison tardive ; nous en etudions les proprietes syntaxiques et la semantique. Certaines variantes sont definies afin de modeliser d'autres constructions des langages objets et afin d'etudier l'optimisation de ces langages a la compilation. Nous utilisons ces variantes pour interpreter un langage objet simple et montrer la correction de son systeme de types. Nous passons ensuite a l'etude des formalismes de second ordre: nous montrons comment rendre decidable fsub et comment l'etendre par la surcharge avec liaison tardive, tout en conservant la decidabilite ; nous utilisons cette derniere extension pour resoudre les problemes de perte d'information dans le typage des langages objets et pour suggerer de nouvelles extensions. Cette recherche se situe dans un cadre plus general d'etude de formalismes ou le calcul depend directement des types
The paper surveys the literature on high-level name-passing process calculi, and their extensions... more The paper surveys the literature on high-level name-passing process calculi, and their extensions with cryptographic primitives. The survey is by no means exhaustive, for essentially two reasons. First, in trying to provide a coherent presentation of different ideas and techniques, one inevitably ends up leaving out the approaches that do not fit the intended roadmap. Secondly, the literature on the subject has been growing at very high rate over the years. As a consequence, we decided to concentrate on few papers that introduce the main ideas, in the hope that discussing them in some detail will provide sufficient insight for further reading.
Uploads
Papers by Giuseppe Castagna