Python implementation of the reticulate specification — lattice checker, conformance testing, and protocol extraction
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reticulate-1.0.0.tar.gz.
File metadata
- Download URL: reticulate-1.0.0.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7427cdcd1875d8d3c02201203bd80d3b015f551a6d360d8fa48917b32cd325ca
|
|
| MD5 |
884734d721e062b9701b1152b71587e8
|
|
| BLAKE2b-256 |
0838029e2fe67e29d7970597a34c83ccdd4186fcfa43fef72792d8a5b7bdca2c
|
File details
Details for the file reticulate-1.0.0-py3-none-any.whl.
File metadata
- Download URL: reticulate-1.0.0-py3-none-any.whl
- Upload date:
- Size: 44.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
809f9b44c0ce9e52d0da8c199f42ac5c3ad786650b39a4fda8b561e7fab73d51
|
|
| MD5 |
a5e88916fb9af8e6e0d796541c14832f
|
|
| BLAKE2b-256 |
fbc9364d2dcf4765df4b68a315068e917826ce74d087b2759c849e5e2b26461d
|