Type checking a multithreaded functional language with session types (original) (raw)
Related papers
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.
Session types for inter-process communication
2003
We define a language whose type system, incorporating session types, allows complex protocols to be specified by types and verified by static typechecking. Although session types are well understood in the context of the π-calculus, our formulation is based on λ-calculus with side-effecting input/output operations and is different in significant ways. 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 channel types. After formalising the syntax, semantics and typing rules of our language, and proving a subject reduction theorem, we outline some possibilities for adding references, objects and concurrency.
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
Type-based information flow analysis for the π-calculus
Acta Informatica, 2005
We propose a new type system for information flow analysis for the π-calculus. As demonstrated by recent studies, information about whether each communication succeeds is important for precise information flow analysis for concurrent programs. By collecting such information using ideas of our previous type systems for deadlock/livelock-freedom, our type system can perform more precise analysis for certain communication/synchronization patterns (like synchronization using locks) than previous type systems. Our type system treats a wide range of communication/synchronization primitives in a uniform manner, which enabled development of a clear proof of type soundness and a sound and complete type inference algorithm.
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.
Verified Linear Session-Typed Concurrent Programming
22nd International Symposium on Principles and Practice of Declarative Programming
We present a system of linear session types that integrates several features aimed at verification of different properties of concurrent programs, specifically types indexed with arithmetic expressions, linear constraints and quantification. We prove the standard type safety properties of session fidelity and deadlock freedom. In order to control the verbosity of programs we introduce implicit syntax and an algorithm for reconstruction, which is complete under some mild assumptions on the structure of types. We then illustrate the expressive power of our language (called Rast) with a variety of examples, including normalization for the linear λ-calculus, balanced ternary arithmetic, binary counters and tries. CCS CONCEPTS • Theory of computation → Linear logic; Type theory; • Computing methodologies → Concurrent programming languages.
2005
We introduce a novel way to integrate functional and concurrent programming based on intuitionistic linear logic. The functional core arises from interpreting proof reduction as computation. The concurrent core arises from interpreting proof search as computation. The two are tightly integrated via a monad that permits both sides to share the same logical meaning for the linear connectives while preserving their different computational paradigms. For example, concurrent computation synthesizes proofs which can be evaluated as functional programs. We illustrate our design with some small examples, including an encoding of the pi-calculus.
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.
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.
A Type System for Lock-Free Processes
Information and Computation, 2002
Advanced type systems for the π-calculus have recently been proposed to guarantee deadlock-freedom in the sense that certain communications will eventually succeed unless the whole process diverges. Although such guarantees are useful for reasoning about the behavior of concurrent programs, there still remains the weakness that the success of a communication is not completely guaranteed due to the possibility of divergence. For example, although a server process that has received a request message cannot discard the request, it is allowed to infinitely delegate the request to other processes, causing a livelock. In this paper, we present a type system which guarantees that certain communications will eventually succeed under fair scheduling, regardless of whether processes diverge. We also present a variant of the type system which guarantees that a communication will succeed within a given number of reduction steps.