CoreFi: A Core Calculus for Embedded Systems with Bounded Shared-Memory Channels
Yan Liu, Alex Potanin
cs.PL
Nov 30, 2026 · v1
cs.LO cs.OS
TL;DR
Semantics, deadlock-freedom, determinism, and refinement theorems of the CoreFi calculus are mechanised in Lean 4 using CSLib, developed with a coding agent.
Abstract
Embedded systems are built from components that compute on private state and communicate over bounded buffers in shared memory; since a component must keep running rather than wait on a slower one, a sender drops a message when the buffer is full, and a receiver blocks when it is empty. Process calculi, the established basis for reasoning about communicating systems, model these channels as bounded queues that block a sender when full. The code itself, written in a low-level language such as C, intertwines computation and communication so tightly that the protocol is hard to recover for verification. We present CoreFi, a core calculus for embedded systems with bounded shared-memory channels, derived from Communicating Sequential Processes (CSP), that addresses both. Our channel semantics is faithful to embedded practice, and we extend CSP's abstract events to concrete computation events, calls to foreign functions, so that a component's program in CoreFi becomes an orchestration of its communication and computation events. Components are composed by the scheduling logic of the underlying kernel rather than by a parallel operator; we instantiate it on the verified microkernel seL4 and its MicroKit framework. Deadlock freedom and determinism are two fundamental properties of embedded systems, and we prove both for every well-formed system, that is, one whose communication dependencies are acyclic and whose guarded choices partition the state space. Separating computation from communication also separates local from global state change: computation events can be absorbed into big steps, and a refinement relation guarantees that trace properties proved on the smaller abstracted model hold of the complete one. We provide the formalisation and the proofs in Lean 4, assisted by a coding agent.
Problem
Embedded systems communicate over bounded shared-memory buffers that drop messages when full. Process calculi model channels as queues that block senders instead. C code also interleaves computation and communication so tightly that the protocol is hard to recover for verification.
Approach
CoreFi is a CSP-derived core calculus with bounded drop-on-full asynchronous channels, synchronous rendezvous channels, and computation events that call foreign functions. Components are composed by the kernel's scheduling logic, instantiated for seL4 MicroKit. An abstraction hides computation events and collapses them into big steps, with a refinement relation preserving channel traces. Everything is mechanised in Lean 4 with CSLib, assisted by a coding agent.
Results
Proved that every system keeps its buffers within capacity. Every well-formed system (acyclic dependencies, partitioned guarded choices) is deadlock-free and deterministic. The abstracted model has exactly the channel traces of the full model. The Lean mechanisation exposed a deadlock and a non-determinism hole in earlier rule versions; the development is released as open source.