Hypha - Type Reconstruction for the Linear π-Calculus
Hypha is a prototype implementation of the type reconstruction algorithm described in Type Reconstruction for the Linear π-Calculus with Composite and Equi-Recursive Types. It is implemented in Haskell, comes with the full source code (see the download section below) and a bunch of examples.
- Release history
- Download the source code
- Have a look at the syntax of processes accepted by Hypha
- Check out some references on the linear π-Calculus
History
- 13 Aug 2014: the internals of Hypha have been completely reworked. Hypha now implements an efficient use resolution algorithm, disjoint sums have been replaced by variant types, and the syntax of processes has been revised. Lots of new interesting examples can be typed!
- 29 Nov 2013: added support for fst and snd operators as suggested by one of the FoSSaCS reviewers; generalized syntax for sends and receives, now the subject can be an arbitrary expression.
- 30 Aug 2013: initial release.
Download
The source code of Hypha can be downloaded at the links below. You need GHC, Alex and Happy to compile the tool. The easiset way to get them all at once is to install the Haskell Platform. In addition, you must install the Haskell packages base-unicode-symbols, containers-unicode-symbols, and multiset. A Makefile is provided.
Example
Below are three processes that visit a binary tree where each node contains a channel: take sends a message on the channel found on any node that is reachable through an even number of right branches from the root of the tree; skip sends a message on the channel found on any node that is reachable through an odd number of right branches from the root of the tree; overall, all sends a message on every channel in the tree.
The types inferred by Hypha reflect the behavior of the three processes:
Syntax
Below is the EBNF grammar describing the syntax of processes accepted by Hypha. The symbols ⇒ ≤ ≥ ≠ × ∧ ∨ ¬ can also be entered as => <= >= <> * /\ \/ not respectively.
Process | ::= | Expression! | Expression . Processoutput |
| | Expression? | Pattern . Processinput | |
| | let Pattern = Expression in Process | local binding | |
| | def Definition | and Definitiondefinitions | |
| | case Expression of { Rule | ; Rule }pattern matching | |
| | if Expression then Process else Process | conditional | |
| | Process | Process | parallel composition | |
| | new var | : Type in Processnew channel | |
| | { | Process }group | |
| | *Process | replication | |
Definition | ::= | var? | Pattern = Processpersistent input |
Rule | ::= | tag | Pattern ⇒ Processmatch |
Pattern | ::= | () | unit |
| | _ | : Typeanonymous | |
| | var | : Typevariable | |
| | Pattern as var | : Typeascription | |
| | Pattern, Pattern | pair | |
| | (Pattern) | group | |
Expression | ::= | () | unit |
| | n | integer | |
| | true | boolean true | |
| | false | boolean false | |
| | var | variable | |
| | unop Expression | unary operator | |
| | Expression binop Expression | binary operator | |
| | (Expression) | group | |
Type | ::= | Unit | Bool | Int | basic types |
binop | ::= | ∧ | ∨ | < | > | ≤ | ≥ | = | ≠ | + | - | × | / | , | binary operators |
unop | ::= | tag | ¬ | fst | snd | unary operators |
var | ::= | a-z a-z 0-9 _ ' | variable |
tag | ::= | A-Z a-z 0-9 _ ' | tag |
n | ::= | 0-9 | integer |
References
- Luca Padovani, Type Reconstruction for the Linear π-Calculus with Composite and Equi-Recursive Types, in Proceedings of FoSSaCS 2014.
- Atsushi Igarashi, Naoki Kobayashi, Type Reconstruction for Linear π-Calculus with I/O Subtyping, Information and Computation, 161(1):1-44, 2000
- Naoki Kobayashi, Benjamin C. Pierce, David N. Turner, Linearity and the pi-calculus, ACM Transactions on Programming Languages and Systems, 21(5):914-947, ACM, 1999