From Constraints to Causality: Petri net Encodings for Explaining Binary Neural Network Inference

Alex Chan, Mohamed Tarraf, Alex Yakovlev, Rishad ShafikarXiv 2026 · DOI

TL;DR

Researchers have developed a way to translate Binary Neural Networks (BNNs) into 1-safe Petri nets, turning "black box" inference into a transparent, executable sequence of discrete events. This approach allows engineers to trace the exact causal path of a decision, making it possible to pinpoint which specific internal computations lead to a classification change.

What Problem Does This Paper Address?

Binary Neural Networks (BNNs) are the darlings of edge computing. By constraining weights and activations to just two values (typically -1 and +1), they replace expensive floating-point math with simple bitwise operations, making them ideal for autonomous systems and wearable devices.

However, BNNs are notoriously difficult to trust in safety-critical settings. While existing formal verification tools (like SAT or SMT solvers) can prove that a network is robust, they treat the model as a "monolithic constraint system." They can tell you that an input leads to an output, but they can't easily show you how the internal logic arrived there. This lack of visibility makes debugging unexpected behavior—like a self-driving car misclassifying a road boundary—extremely difficult for engineers who need to know if a failure is a systematic flaw or a one-off fluke.

Methods

The authors propose a compositional translation from the inference semantics of a trained BNN into a 1-safe Petri net (PN). A Petri net is a mathematical modeling language used to describe distributed systems; it consists of "places" (states) and "transitions" (events).

Key aspects of their encoding include:

  • Input Loading: A dedicated PN segment (see Figure 1) that handles data points either sequentially for testing or non-deterministically for exhaustive verification.
  • Discrete-Event Inference: Since Petri nets aren't designed for arithmetic, the authors represent each possible input-weight multiplication and summation step as explicit transitions. For example, a neuron's "Sign" activation function is modeled as a block that moves tokens to specific output places based on the accumulated sum.
  • 1-Safe Property: The resulting net is "1-safe," meaning no place ever holds more than one token at a time, which simplifies formal analysis.
Figure 1: PN segment for loading the datapoints. The inference block abstracts the pipeline of Figure 2 with the blue arrow indicating the multiplication places it consumes, while the other dashed boxes group the places and transitions repeated for each feature (x1 to xD) and neuron (n1 to nH).

The researchers used the WORKCRAFT toolset and the MPSAT backend to perform reachability analysis on these models, allowing them to verify properties by checking if certain "firing sequences" (sequences of events) are possible.

Datasets

The paper focuses on a "worked example" rather than a large-scale benchmark to establish the foundational theory. They evaluate a trained BNN with:

  • 2 input features
  • 1 hidden layer with 2 neurons
  • 1 output neuron

While small, this setup allows for exhaustive input-output equivalence checking, ensuring the Petri net perfectly mimics the original BNN's logic across all possible input combinations.

Key Insights and Ideas

  • Causality over Constraints: Unlike SAT solvers that provide a static "snapshot" of why a property holds, the Petri net provides a causal trace. You can literally watch the "tokens" flow through the network's logic.
  • Fault Localization via Counterfactuals: By comparing the firing sequences of a reference input and a "perturbed" input (where one feature is flipped), the authors can identify exactly where the internal computations diverge.
  • Concurrency by Design: Petri nets naturally represent the concurrent nature of neural networks, where multiple neurons in a layer process information simultaneously.
Figure 2: Inference pipeline for the worked example (D = 2) showing Neuron 1 with the output-layer aggregation (Z) and prediction (Pred). Neuron 2 is identical to Neuron 1 up to its weights, and labelled arc endpoints denote its output places. Transitions are named by the values they consume, e.g. nve1pve1 in a multiplication segment fires for input −1 and weight +1, corresponding to t(−1×+1) in Table 2.

Key Results

The authors successfully demonstrated faithfulness: the Petri net produced the exact same outputs as the reference BNN for all $2^D$ possible inputs.

In a practical demonstration of explainability, they showed how flipping a single input feature ($x_2$) changed a prediction from -1 to +1. By contrasting the firing sequences (see Table 2 below), they localized the decision change to Neuron 2. They observed that while Neuron 1's internal state also changed, its output remained the same, whereas Neuron 2's activation "flipped," ultimately driving the final prediction change. This level of structural insight is something standard constraint-based verifiers cannot provide.

Table 2: Firing sequences of the reference and perturbed inputs, grouped by causal chain. Neuron 1 and Neuron 2 chains are concurrent, while the output chain depends on both. Bold entries mark transitions that fire differently between the two runs.

Limitations and Future Work

As this is "early work," there are several hurdles to clear before this hits production:

  • Scalability: Reachability analysis is computationally expensive. While the 66-place model was checked in under 0.1 seconds, larger networks will face a "state space explosion."
  • Architectural Scope: The current encoding only supports fully connected (dense) layers. Future work is needed to adapt the method for convolutional and pooling layers.
  • Automation: The authors aim to develop a "correctness-of-translation" theorem and automate the extraction of causal traces to help designers compare different trained models.

Summary updated

Abstract

Binary Neural Networks (BNNs) are attractive for resource-constrained hardware and on-device components in autonomous systems. However, their discrete, non-linear behaviour makes them difficult to analyse and trust in safety-relevant settings. Existing approaches based on SAT and Satisfiability Modulo Theories can verify a BNN's input-output properties, but treat it as a monolithic constraint system, which reveal only whether a property holds and not how the computation reaches its result. In this paper, we present an early work that provides a complementary, discrete-event view. We give a compositional translation from the inference semantics of a fixed, trained BNN to a 1-safe Petri net (PN), where each computation step is an explicit transition, so that a firing sequence is a causal trace of the BNN's decision. On a worked example, we establish faithfulness via exhaustive input-output equivalence against a reference implementation, and show how contrasting firing sequences localises where a single-feature change alters the prediction. Finally, we outline two directions this opens: a correctness-of-translation theorem, and a causal-trace analysis of where two trained BNNs diverge in their decisions, a structural question that constraint-based verifiers cannot express.
BibTeX
@misc{chan2026from,
  author = {Alex Chan and Mohamed Tarraf and Alex Yakovlev and Rishad Shafik},
  title = {{From Constraints to Causality: Petri net Encodings for Explaining Binary Neural Network Inference}},
  year = {2026},
  eprint = {2611.22396},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.22396},
}
Figure