Semantics of
Reversible Concurrency

SPLS @ St Andrews

Vikraman Choudhury

MSP, University of Strathclyde, Glasgow, UK

Feb 11, 2026

Introduction

  • Programs run forwards.
  • Sometimes we may want to run them backwards:
    • Reversible functions preserve information (Bennett)
    • Reversible Boolean circuits in quantum computers (Fredkin, Toffoli)
    • Encoders and decoders are partially invertible
    • Reversible debugging
    • Reversible process calculi (Danos, Krivine)
  • Models:
    • Rig groupoids
    • Inverse categories (Cockett)

What does a debugger do?

  • Reversible debuggers record the trace of a program’s execution
  • In debugging mode, the user can step forward and backward through the trace
  • The user can inspect the state of the program at any point in the trace, and look at the events that led to a particular state

Debugging concurrent programs

  • What if the program is concurrent?
  • In a concurrent program, traces are not linear, they are “asynchronous”
  • To step backwards, the debugger needs to know which events are causally related, and which are independent

Concurrent programs

Reversible Process Calculi

(a)
(b)
Figure 1:

Event Structures

An event structure is a:

  • partial order of events \((E, \leq)\), satisfying
    • axiom of finite causes: \(\downset{e} = \{e' \in E \mid e' \leq e\}\) is finite for all \(e \in E\), and
  • a conflict relation \({\confl} \subseteq E \times E\), that is:
    • irreflexive and symmetric, and satisfies
    • axiom of hereditary conflict: if \(e \confl e'\) and \(e' \leq e''\), then \(e \confl e''\).

Two events are concurrent if they are not causally related and not in conflict: \[ e_1 \conc e_2 \iff \neg(e_1 \leq e_2 \lor e_2 \leq e_1 \lor e_1 \confl e_2) \]

Configurations

A (finite) configuration of \((E, \leq, \confl)\) is a subset \(C \subseteq E\) that is:

  • downward-closed: if \(e \in C\) and \(e' \leq e\), then \(e' \in C\), and
  • conflict-free: if \(e, e' \in C\), then \(\neg(e \confl e')\).

The set of all configurations is denoted \(\Conf(E)\), and is ordered by inclusion.

We say \(C \enables e\), or \(C\) enables \(e\), if:

  • \(e \notin C\), and \(C \cup \{e\} \in \Conf(E)\).

\[ E = \{a, b, c\}, \quad {\leq} = \{(a, c), (b, c), (a, a), (b, b), (c, c)\}, \quad {\confl} = \{(b, c), (c, b)\} \]

Transitions between configurations

The initial configuration is \(\emptyset\).

If \(C \enables e\):

  • do a forward transition \(C \flts{e} C \cup \{e\}\), and
  • add a backward transition \(C \cup \{e\} \blts{\overline{e}} C\).

An LTS is a \(P(L \times \blank)\)-coalgebra.

A revLTS is a \(P((L + L) \times \blank)\)-coalgebra.

Two transitions are independent, \((C \lts{e_1} C_1) \ind (C \lts{e_2} C_2)\), if \(e_1 \conc e_2\).

Labelled transition systems with Independence

  • Loop property: if \(C \flts{e} C'\), then \(C' \blts{\overline{e}} C\).
  • Square property:

  • Backward independence property:

Paths and computations

A path between \(C_1\) and \(C_2\) is either:

  • an empty path \(C \lts{\varepsilon} C\), or
  • an edge \(C \lts{e} C'\), followed by a path from \(C'\) to \(C_2\).

Configurations and paths form the free category \(F(E)\) on the labelled graph generated by the event structure.

The independence relation on transitions generates a relation on paths:

  • \(p \approx p\),

  • if \(e_1 \conc e_2\), then \(p \cdot e_1 \cdot e_2 \cdot q \approx q \cdot e_2 \cdot e_1 \cdot p\).

Configurations and paths form the quotient category of \(F(E)\) by this equivalence relation.

Rollback

Given a configuration \(C\) and an event \(e \in C\), the rollback \(\rollback{C}{e}\) is:

  • a maximal configuration \(C' \subseteq C\) such that \(C' \enables e\), and
  • \(\rollback{C}{e} = C \mathrel{\setminus} \downset{e}\),
  • hence maximum.

Rollback satisfies the following properties:

  • Redoability: event \(e\) can be executed in \(\rollback{C}{e}\),
  • Causal safety: \(\rollback{C}{e}\) contains no consequences of events that were rolled back,
  • Correctness: \(C\) can be reached from \(\rollback{C}{e}\), and
  • Minimality: there is no \(C'\) satisfying the above properties such that the path from \(C'\) to \(C\) is shorter than the path from \(\rollback{C}{e}\) to \(C\).

Replay

To replay a computation starting at a configuration, we pick a causally-consistent log.

\(e_1\) is in minimal conflict with \(e_2\), denoted \(e_1 \minconfl e_2\), if:

  • \(e_1 \confl e_2\), and
  • for all \(e_1' \leq e_1\) and \(e_2' \leq e_2\), if \(e_1' \confl e_2'\), then \(e_1' = e_1\) and \(e_2' = e_2\).

A log of a configuration \(C\) is \(\alog{C} = \{e \in C \mid \exists e' \not\in C, e \minconfl e'\}\).

Replay (contd.)

A computation \(\sigma\) is compatible with a log \(l\) if:

  • for all \(e \in l\), \(e \in \sigma\),
  • for all \(e \in \sigma\), \(e' \in l\), \(\neg(e \confl e')\), and
  • for all \(e \in \sigma\), \(e' \in E\), if \(e \confl e'\) then \(e \in l\).

The set of computations compatible with a log \(l\) is \(\Comp(l)\).

\(\Comp(l)\) has a:

  • minimum element \(\minrepl{l} = \bigcup_{e \in l} \downset{e}\), and
  • maximum element \(\maxrepl{l} = \minrepl{l} \cup \{e \in E \mid \forall e_1, e_2,\, e_1 \minconfl e_2 \land e_1 \leq e \implies e_1 \in l\}\).

Epilogue

  • What has been achieved?
    • An abstract understanding of reversible concurrency.
    • A notion of rollback and replay.
    • Recovers the standard LTS of revCCS (almost).
    • Formalisation in Lean: vikraman/event-structures.
  • Questions:
    • Is this an axiomatisation?
    • Is there a categorical account?
    • Apply this to other models of concurrency?
    • Apply this to other concurrent languages?