In progress
Mechanising CSP in Agda with Process Trees
A coinductive mechanisation of CSP in Agda based on process trees, an extension of interaction trees, covering operators and algebraic laws, failures-divergences refinement, bisimulation and LTL. It is the foundation of my Cardano network verification.
State of the art & contributions
Process algebras such as CSP are usually given an operational semantics as a labelled transition system, with denotational models (traces, failures, divergences) layered on top. This library instead takes a single coinductive process tree as the one semantic object.
The key design is a fused branching node: a single react node carries both a visible offer map (external choice) and a silent τ-branch map (internal choice). Because one node can offer visible events and have an enabled τ at the same time, the model expresses sliding / timeout states directly — something separate visible and branching nodes cannot.
On this one type the library develops the behavioural theories generically, independent of any particular operator set: strong, weak and divergence-respecting bisimulation; stable refusals and stable failures; the failures-divergences model with its refinement orders and equivalence; and an LTL layer. Bridges connect bisimulation to failures-divergences equivalence.
Architecture
The formalisation is layered in Agda:
- Core — the coinductive
PTree E I Rtype with node kindsret,silandreact, universe-polymorphic and parametric in events and internal indices. - Generic semantics — labelled transitions and traces, bisimulations, refusals/failures, the failures-divergences model and refinement orders, and LTL, all defined over the tree without reference to CSP operators.
- CSP layer — operators (prefix, external and internal choice, sliding, parallel, interleaving, hiding, renaming, sequential composition, throw, interrupt, priority, …) as functions over process trees, with their algebraic laws proved mainly in the failures-divergences model.
- Examples — case studies from Roscoe’s The Theory and Practice of Concurrency and Understanding Concurrent Systems, dining philosophers, and a vending machine with LTL satisfaction proofs.

What it can do
- Express CSP processes as a single tree type and define the standard operators over it.
- Prove strong, weak and divergence-respecting bisimulations.
- Reason in the failures-divergences model: refusals, failures, divergences, refinement and equivalence.
- Check LTL properties over process trees.
- Worked examples include deadlock-freedom proofs, LTL satisfaction and textbook case studies.
A probabilistic extension of the process-tree model is planned.
Applications
Cardano network modelling
The library is the semantic basis for modelling and verifying the Cardano peer-to-peer network, developed on kangfeng/* branches of agda-cardano-common:
- Cardano network and mini-protocol model: the node-to-node mini-protocols, the network multiplexer and whole-network systems, with proofs of deadlock freedom, divergence freedom and refinement against specifications.
- Trace verifier for Cardano mini-protocols: checks network logs against session specifications of the mini-protocols.
- Connection manager design and source verification: a source-derived model of connection management used to confirm design guarantees, report issues and suggest fixes.
Security protocols
The process-tree model underpins a framework for verifying security protocols in Agda. A protocol is written as role terms in a small modelling language and composed in parallel with a Dolev–Yao intruder; secrecy and agreement are stated as trace refinements, proved with rank functions in the style of Schneider, and negative results are refutations at concrete traces of the same composition.
Worked examples include:
- a Diffie–Hellman family — signed, unsigned and classic Diffie–Hellman, plus DHDS — with secrecy, agreement, perfect-forward-secrecy and hybrid-key claims, and their man-in-the-middle / unknown-key-share calibrations;
- Needham–Schroeder public-key and Lowe’s fixed NSL variants, including key-server and replicated-session forms;
- an indistinguishability layer for observation-based equivalence proofs, with adapters for Helios (voting) and a basic access-control protocol.
How to use it
With Agda 2.8.0 and the standard-library and standard-library-classes libraries installed, type-check from the repository root:
agda src/CSP/Operators.agda
Modules are type-checked transitively, so checking an entry point pulls in its dependencies. The library is laid out under src/, with Semantics/ for the generic theory and CSP/ for the operators, laws and examples.