Abstract

Session types statically describe communication protocols between concurrent message-passing processes. Unfortunately, parametric polymorphism even in its restricted prenex form is not fully understood in the context of session types. In this paper, we present the metatheory of session types extended with prenex polymorphism and, as a result, nested recursive datatypes. Remarkably, we prove that type equality is decidable by exhibiting a reduction to trace equivalence of deterministic first-order grammars. Recognizing the high theoretical complexity of the latter, we also propose a novel type equality algorithm and prove its soundness. We observe that the algorithm is surprisingly efficient and, despite its incompleteness, sufficient for all our examples. We have implemented our ideas by extending the Rast programming language with nested session types. We conclude with several examples illustrating the expressivity of our enhanced type system.

Highlights

  • We focus on binary session types that describe bilateral protocols between two endpoint processes performing dual actions

  • Prior work has restricted itself to parametric polymorphism either: in prenex form without nested types [26,45]; with explicit higher-rank quantifiers [6,38] but without general recursion; or in specialized form for iteration at the type level [46]. None of these allow a free, nested use of polymorphic type constructors combined with prenex polymorphism

  • In connection with context-free session types (CFSTs), we identified a proper fragment of nested session types closed under sequential composition and nested session types are strictly more expressive than CFSTs

Read more

Summary

Introduction

Session types express and enforce interaction protocols in message-passing systems [29,44]. Prior work has restricted itself to parametric polymorphism either: in prenex form without nested types [26,45]; with explicit higher-rank quantifiers [6,38] (including bounded ones [24]) but without general recursion; or in specialized form for iteration at the type level [46]. We show that we can translate type equality for nested session types to the trace equivalence problem for deterministic first-order grammars, shown to be decidable by Jancar, albeit with doubly-exponential complexity [31]. The difference is that the standard session type equality is defined coinductively, as a bisimulation, rather than via language equivalence [23]. – A proper fragment of nested session types that is closed under sequential composition, the main feature of context-free session types (Section 7). – A proof of decidability of type equality (Section 4). – A practical algorithm for type equality and its soundness proof (Section 5). – A proper fragment of nested session types that is closed under sequential composition, the main feature of context-free session types (Section 7). – An implementation and integration with the Rast language (Section 8)

Overview of Nested Session Types
Description of Types
Type Equality
Type Equality Definition
Decidability of Type Equality
Practical Algorithm for Type Equality
Type Equality Declarations
Formal Language Description
Basic Session Types
Type Safety
Relationship to Context-Free Session Types
Implementation
More Examples
10 Further Related Work
11 Conclusion
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call