Reticulate
A Python tool for lattice analysis of session type state spaces.
Given a session type definition, Reticulate constructs the state-space labeled transition system, computes its SCC quotient, checks whether the quotient forms a bounded lattice, and optionally generates a Hasse diagram. Part of the Session Types as Algebraic Reticulates research project.
Requirements
- Python 3.11+
- Optional:
graphvizPython package + system binary (for Hasse diagram rendering)
Installation
# Install from source
pip install .
# With visualisation support
pip install .[viz]
# Development (editable + pytest)
pip install -e .[dev]
This installs the session2lattice command (plus aliases s2l, sess2lat, lattice-check, bica).
Usage
Command Line
# Basic lattice check
session2lattice "rec X.&{a:X, b:end}"
# Show version
session2lattice --version
# Generate DOT output for Hasse diagram
session2lattice --dot "rec X.&{a:X, b:end}"
# Render Hasse diagram to file
session2lattice --hasse output "&{m: end, n: end}"
# Check distributivity (Birkhoff classification)
session2lattice --distributive "(&{a: end} || &{b: end})"
# Pretty-print lattice tables (states, transitions, meet/join)
session2lattice --lattice "&{a: end, b: end}"
# Generate JUnit test source
session2lattice --test-gen --class-name FileHandle "&{open: &{read: end, close: end}}"
# All options
session2lattice --help
As a Library
from reticulatep import parse, build_statespace, check_lattice
# Parse a session type
st = parse("rec X.&{a:X, b:end}")
# Build state space
ss = build_statespace(st)
# Check lattice property
result = check_lattice(ss)
print(f"Is lattice: {result.is_lattice}")
print(f"States: {len(ss.states)}, SCCs: {len(set(result.scc_map.values()))}")
Session Type Grammar
S ::= &{ m1 : S1 , ... , mn : Sn } -- branch (external choice)
| +{ l1 : S1 , ... , ln : Sn } -- selection (internal choice)
| ( S1 || S2 ) -- parallel composition
| rec X . S -- recursion
| X -- variable
| end -- terminated
Unicode alternatives: ⊕ for +, ∥ for ||, μ for rec.
Modules
Core
| Module | Description |
|---|---|
parser.py |
Recursive-descent parser, 8 AST nodes, pretty-printer |
sugar.py |
Syntactic sugar: desugar / ensugar transformations |
statespace.py |
State-space construction by structural induction |
product.py |
Product construction for parallel composition |
lattice.py |
SCC quotient, reachability, lattice + distributivity checking |
termination.py |
Termination checking, WF-Par well-formedness |
recursion.py |
Guardedness, contractivity, unfolding, SCC analysis |
Analysis
| Module | Description |
|---|---|
morphism.py |
Morphism hierarchy (isomorphism, embedding, projection, Galois) |
subtyping.py |
Gay–Hole subtyping on ASTs, width embedding verification |
duality.py |
Session type duality (Branch ↔ Select), involution check |
endomorphism.py |
Transition endomorphism analysis (order/meet/join preservation) |
reticular.py |
Reticular form characterisation and reconstruction |
enumerate_types.py |
Exhaustive session type enumeration (universality check) |
context_free.py |
Chomsky classification (regular vs context-free) |
polarity.py |
Polarity analysis, concept lattice, Galois pairs |
realizability.py |
Realizability conditions, obstruction detection |
Multiparty
| Module | Description |
|---|---|
global_types.py |
Multiparty global type AST, parser, state-space |
projection.py |
MPST projection: global → local types |
composition.py |
Binary/n-ary composition, synchronized product |
composition_viz.py |
Composition dashboard visualisation |
channel.py |
Synchronous channel construction |
async_channel.py |
Asynchronous channel with buffer semantics |
Output
| Module | Description |
|---|---|
visualize.py |
Hasse diagram generation (DOT/Graphviz) |
testgen.py |
JUnit/TestNG test generation from state spaces |
coverage.py |
Test coverage analysis and storyboard rendering |
cli.py |
Command-line interface (13 flags) |
Tests
# Run all tests (2,481 tests)
python -m pytest tests/ -v
# Run specific test module
python -m pytest tests/test_lattice.py -v
# Run benchmarks only
python -m pytest tests/benchmarks/ -v
Benchmarks
79 binary and 24 multiparty real-world protocol benchmarks are included in tests/benchmarks/, spanning networking (SMTP, HTTP, DNS, TLS, MQTT), databases (JDBC, Redis), distributed systems (Raft, 2PC, Saga), security (OAuth 2.0), AI agents (MCP, A2A), and more. All form bounded lattices.
Reference
This tool accompanies the paper:
A. Z. Caldeira and V. T. Vasconcelos. "Session Type State Spaces Form Lattices." ICE 2026.
License
MIT License. See LICENSE.
Release files for reticulate 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| reticulate-1.0.1.tar.gz | 41.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| reticulate-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 87.1 kB
Release files / reticulate-1.0.1.tar.gz
| Download URL | reticulate-1.0.1.tar.gz |
|---|---|
| Size | 41.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ce9aec4573f5d3a16b68f66ae5ef063937aeb4dd4fcd0a59a37efc1183e80e5
|
|
BLAKE2b-256 checksum How to use checksums |
0bbe77ef10b79ddd45e5cb2f65928055db12bda5d38a4bf6ab02f29e9a01f2f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / reticulate-1.0.1-py3-none-any.whl
| Download URL | reticulate-1.0.1-py3-none-any.whl |
|---|---|
| Size | 45.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68b9c171941a18ea96a785fb3b8a4b91f0f519dd78ec1619d98153ec71e3ba01
|
|
BLAKE2b-256 checksum How to use checksums |
0b05098f261ff3f6b2a250d8ef35a2a3be86aae67b53f15f461976b0cc076f33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|