libpetri — Coloured Time Petri Net Engine
A high-performance Petri net engine with formal verification support.
Quick Start
use *;
let p1 = new;
let p2 = new;
let t = builder
.input
.output
.action
.build;
let net = builder.transition.build;
let mut marking = new;
marking.add;
let mut executor = new;
executor.run_sync;
assert_eq!;
Example: Basic Chain
Example: Order Processing Pipeline
A showcase net demonstrating all arc types (input, output, read, inhibitor, reset), both place types (regular + environment), all timing modes (immediate, deadline, delayed, window, exact), and patterns (AND-fork, AND-join, XOR, priority).
Crate Structure
- [
core] — Places, tokens, transitions, timing, actions - [
event] — Event store for recording execution events - [
runtime] — Bitmap-based executor (sync + async) - [
export] — DOT/Graphviz export pipeline - [
verification] — Formal verification (P-invariants, state class graphs, SMT)
Executors
Two executors are available:
- [
BitmapNetExecutor] — General-purpose, bitmap-based enablement checks - [
PrecompiledNetExecutor] — High-performance alternative with ring buffers, opcode dispatch, and two-level summary bitmaps
Feature Flags
| Feature | Effect |
|---|---|
tokio |
Enables run_async() on both executors (external event injection) |
z3 |
Enables SMT-based IC3/PDR model checking in [verification] |
debug |
Enables the debug module (WebSocket debug protocol) |