Session types for inter-process communication (original) (raw)
Related papers
Type checking a multithreaded functional language with session types
Theoretical Computer Science, 2006
We define a language whose type system, incorporating session types, allows complex protocols to be specified by types and verified by static typechecking. A session type, associated with a communication channel, specifies the state transitions of a protocol and also the data types of messages associated with transitions; thus typechecking can verify both correctness of individual messages and correctness of sequences of transitions. Previously, session types have mainly been studied in the context of the π-calculus; instead, our formulation is based on a multi-threaded functional language with side-effecting input/output operations. Our typing judgements statically describe dynamic changes in the types of channels, and our function types not only specify argument and result types but also describe changes in channels. We formalize the syntax, semantics and type checking system of our language, and prove subject reduction and runtime type safety theorems.
Session Types as Generic Process Types
Electronic Proceedings in Theoretical Computer Science, 2014
Behavioural type systems ensure more than the usual safety guarantees of static analysis. They are based on the idea of "types-as-processes", providing dedicated type algebras for particular properties, ranging from protocol compatibility to race-freedom, lock-freedom, or even responsiveness. Two successful, although rather different, approaches, are session types and process types. The former allows to specify and verify (distributed) communication protocols using specific type (proof) systems; the latter allows to infer from a system specification a process abstraction on which it is simpler to verify properties, using a generic type (proof) system. What is the relationship between these approaches? Can the generic one subsume the specific one? At what price? And can the former be used as a compiler for the latter? The work presented herein is a step towards answers to such questions. Concretely, we define a stepwise encoding of a π-calculus with sessions and session types (the system of Gay and Hole [4]) into a π-calculus with process types (the Generic Type System of Igarashi and Kobayashi [6]). We encode session type environments, polarities (which distinguish session channels end-points), and labelled sums. We show forward and reverse operational correspondences for the encodings, as well as typing correspondences. To faithfully encode session subtyping in process types subtyping, one needs to add to the target language record constructors and new subtyping rules. In conclusion, the programming convenience of session types as protocol abstractions can be combined with the simplicity and power of the π-calculus, taking advantage in particular of the framework provided by the Generic Type System. Session types are an increasingly popular technique for specifying and verifying protocols in concurrent and distributed systems. In a setting of point-to-point private-channel-based communication, the session type of a channel describes the sequence and type of messages that can be sent on it. For example
Session Types for Functional Multithreading
Lecture Notes in Computer Science, 2004
We define a language whose type system, incorporating session types, allows complex protocols to be specified by types and verified by static typechecking. A session type, associated with a communication channel, specifies the state transitions of a protocol and also the data types of messages associated with transitions; thus typechecking can verify both correctness of individual messages and correctness of sequences of transitions. Previously session types have mainly been studied in the context of the π-calculus; instead, our formulation is based on a multi-threaded functional language with side-effecting input/output operations. Our typing judgements statically describe dynamic changes in the types of channels, our channel types statically track aliasing, and our function types not only specify argument and result types but also describe changes in channels. We formalize the syntax, semantics and typing rules of our language, and prove subject reduction and runtime type safety theorems.
An Implementation of Session Types
Lecture Notes in Computer Science, 2004
A session type is an abstraction of a set of sequences of heterogeneous values sent and received over a communication channel. Session types can be used for specifying stream-based Internet protocols. Typically, session types are attached to communication-based program calculi, which renders them theoretical tools which are not readily usable in practice. To transfer session types into practice, we propose an embedding of a core calculus with session types into the functional programming language Haskell. The embedding preserves typing. A case study (a client for SMTP, the Simple Mail Transfer Protocol) demonstrates the feasibility of our approach.
Session Types for Object-Oriented Languages
Lecture Notes in Computer Science, 2006
A session takes place between two parties; after establishing a connection, each party interleaves local computations and communications (sending or receiving) with the other. Session types characterise such sessions in terms of the types of values communicated and the shape of protocols, and have been developed for the π-calculus, CORBA interfaces, and functional languages. We study the incorporation of session types into object-oriented languages through MOOSE, a multi-threaded language with session types, thread spawning, iterative and higher-order sessions. Our design aims to consistently integrate the objectoriented programming style and sessions, and to be able to treat various case studies from the literature. We describe the design of MOOSE, its syntax, operational semantics and type system, and develop a type inference system. After proving subject reduction, we establish the progress property: once a communication has been established, well-typed programs will never starve at communication points.
Structuring Communication with Session Types
Lecture Notes in Computer Science, 2014
Session types are types for distributed communicating processes. They were born from process encodings of data structures and typical interaction scenarios in an asynchronous version of the π-calculus, and are being studied and developed as a potential basis for structuring concurrent and distributed computing, as well as in their own right. In this paper, we introduce basic ideas of sessions and session types, outline their key technical elements, and discuss how they may be usable for programming, drawing from our experience and comparing with existing paradigms, especially concurrent objects such as actors. We discuss how session types can offer a programming framework in which communications are structured both in program text and at run-time.
Type Inference for Session Types in the \pi -calculus
Lecture Notes in Computer Science, 2016
In this paper we present a direct algorithm for session type inference for the π-calculus. Type inference for session types has previously been achieved by either imposing limitations and restriction on the π-calculus, or by reducing the type inference problem to that for linear types. Our approach is based on constraint generation and solving. We generate constraints for a process based on its syntactical components, and afterwards solve the generated constraints in a predetermined order. We prove the soundness, completeness, and termination of this approach.
Bounded Session Types for Object Oriented Languages
Lecture Notes in Computer Science, 2007
A session takes place between two parties; after establishing a connection, each party interleaves local computations and communications (sending or receiving) with the other. Session types characterise such sessions in terms of the types of values communicated and the shape of protocols, and have been developed for the π-calculus, CORBA interfaces, and functional languages. We study the incorporation of session types into object-oriented languages through MOOSE, a multi-threaded language with session types, thread spawning, iterative and higher-order sessions. Our design aims to consistently integrate the objectoriented programming style and sessions, and to be able to treat various case studies from the literature. We describe the design of MOOSE, its syntax, operational semantics and type system, and develop a type inference system. After proving subject reduction, we establish the progress property: once a communication has been established, well-typed programs will never starve at communication points.
Operational semantics and type system for Gnome on Typed Calculus of Objects
We present an operational semantics and a typing assignment system for the concurrent object-oriented speci cation language Gnome, based on a name-passing asynchronous calculus of concurrent objects, TyCO. The operational semantics is given by a map encoding Gnome classes in TyCO agents, and thus, objects (instances of classes) in processes (instances of agents). We propose a general approach to implement synchronous communication in an asynchronous process calculus, using a commit-abort protocol, achieving by this means the synchronization of all objects involved on a transaction. We treat objects with internal animation, their dynamic creation and deletion. Furthermore, the method generates a (decidable) typing assignment system that ensures lack of runtime errors for typable programs. The type of an agent certi cates the communicating protocol of the corresponding class.
A pi-calculus with dynamic typing
Traditional static typing systems for the pi-calculus are built around capability types that control the read/write access rights on channels and describe the type of their payload. While static typing has proved adequate for reasoning on process behavior in typed contexts, dynamic techniques have often been advocated as more effective for access control in distributed/untyped contexts. Here we develop a new typing discipline for the asynchronous pi-calculus, which we call API@. It combines static and dynamic typing: a static type system associates channels with flat types that only express read/write capabilities and disregard the payload type; a dynamically typed synchronization complements the static type system to guarantee type soundness. We define a typed equational theory, and we give a co-inductive proof technique useful to prove equivalences among processes. We study the relationships between our dynamic approach and the static one of the asynchronous pi calculuS, referred as API, which comes with an entirely standard static typing system. On the one hand, we show that API can be encoded in API@ in a sound manner. On the other hand, we show that API@ can be encoded into API in a fully abstract manner, preserving the respective behavioral equivalences of the two calculi. Besides yielding an interesting expressivity result, the encoding also sheds light on the effectiveness of dynamic typing as a mechanism for access control. Here we take P ∼ = @ Q to mean that P and Q are behaviorally indistinguishable, i.e. they have the same observable behavior when executed in any arbitrary context. The equation (1) is easily disproved by exhibiting a context that interferes with the intended protocol between S and C. A first example is the context C 1 [−] = − | d(x).!x(y).0, that initially behaves as the client, to receive s, but then it steals the jobs intended Work partially supported by M.I.U.R (Italian Ministry of Education, University and Research) under contract n. 2005015785.