arXiv:2610.08750cs.LGOct 2026

Manuscript Offprint

arXiv:2610.08750

Neural Petri flows for chemical reactions

Jose Eduardo Escrig Molina, Daniel Probst

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Petri nets, in which transitions move tokens between places, have been used to describe chemical processes such as reactions. Petri net terms map well to chemistry: Places are the bonds between atoms and the free valence of each atom, a token is a unit of bond order, a transition forms or breaks a bond, the conserved quantities are the valence budgets of the atoms, and the enabling rule, that a transition needs tokens on its input places, is the valence rule. These semantics are not guaranteed by learned models of reactions or neural networks that are built on Petri nets, which use the net as a scaffold for message passing. Here, we ask what architecture remains a Petri net for every value of its weights. We find the answer in the theory, where all semantics of a net share the firing form m′=m+Cσm' = m + C\sigma, locality, as enabling reads only the inputs of a transition, and the enabling rule, and we prove that conservation forces the firing form and that non-negativity forces the enabling rule on local rate laws. What this leaves free is the rate law, which is the propensity of each transition to fire. We introduce Neural Petri Flow, which learns this rate law, or a readout for classification, and hard-wires the rest as parameter-free layers. On what we denote a valence net, atom mapping, reaction classification, and forward prediction become three tasks on one firing vector, which is an unordered list of bond changes. Without training, the minimum firing vector maps 88.8 % of the curated Golden set against 85.6 % for RXNMapper, and 88.7 % against 77.9 % of the enzymatic reactions of EnzymeMap. On USPTO-480K, NPF trained on these firing vectors predicts 87.7 % of the products and 67.4 % when trained on a 1 % subset of the training reactions. EC numbers of ECREACT are predicted at the third level for 90.2 % of reactions, 5.6 points ahead of the best published method. With electrons as tokens, the same token game predicts 90.5 % of the elementary steps of FlowER first, ahead of the published baseline, and every top-1 prediction is a valid molecule without a filter.

Keywords chemistry · neural petri nets · reaction prediction atom mapping · reaction classification · enzymology

1 Introduction

Petri nets were devised in order to describe chemical processes [Petri and Reisig, 2008]. While Petri nets became a standard tool for concurrency, chemistry kept them to describe reaction networks, where places are species [Koch, 2010, Baez and Biamonte, 2019]. We take this approach down to chemical bonds of a single reaction, and ask what kind of neural network it takes for its outputs to obey the rules of that net for every value of its weights, as the rules are computed instead of learned. Learning only fills in what the rules leave open, such as which bonds change.

A reaction as a net. Given the heavy atoms, which are all atoms other than hydrogen, of the precursors of a chemical reaction, we define a bond place BijB_{ij} for every pair (i,j)(i,j) of atoms and a slack place SiS_i for every atom ii. Tokens on BijB_{ij} are units of bond order, where a single bond is one token, a double bond is two tokens, and an aromatic bond one and a half. Tokens on SiS_i are units of valence of atom ii not spent on bonds with other heavy atoms, namely, its hydrogens,

A PREPRINT

Figure

(a) valence net

(b) token game

(c) three tasks, one σ\sigma

Figure 1: (a) A reaction as two markings of its valence net. (b) Only the rate law (magenta) is learned. (c) The minimum firing vector σ\sigma maps atoms, trains the token game and feeds the classifier.

its negative charge, and a capacity to become cationic or hypervalent, one token for nitrogen and none for carbon. A marking is the vector of all token counts or, in chemistry terms, a set of molecules. A reaction is then a pair of markings, mAm_A and mBm_B for the reactants and the products, respectively. The two are written on different atoms, and an atom map, which assigns every product atom to the matching precursor atom, makes them markings of one net. Transitions tt are elementary bond changes, where, for every atom pair (i,j)(i, j) and every amount δ\delta, a transition takes δ\delta tokens from each of SiS_i and SjS_j and puts δ\delta tokens on BijB_{ij}, forming a bond of order δ\delta. The reverse operation breaks the bond. Firing a transition is the realisation of that bond change, and the firing-count vector σ\sigma, firing vector for short, counts the firings of every transition, describing a reaction as an unordered list of bond changes. The state equation mB=mA+Cσm_B = m_A + C\sigma reads products = precursors + bond changes, where the matrix CC records which places each transition empties and fills. The PP-invariants are the quantities no firing can change, namely, the valence budgets of the atoms, each the bond orders plus its free valence of an atom. The enabling rule that states that a transition may only fire when its input places hold enough tokens, is the valence rule. For example, a carbon with four bonds to other heavy atoms has to break one before it can form another. This net, the valence net of the reaction, has no parameters, as it is fixed by the precursor atoms and the rules of valence.

Sequence models can write strings that are not a valid molecule, and electron-flow and graph-edit models can predict bond changes that are not guaranteed to respect valence for every output. Stated in net terms, the outputs of these models are not markings (states) that any firing sequence can reach. Current Petri graph neural networks pass messages between places and transitions, using the net as a computation graph, but the states they update are not markings [Hu et al., 2020, Ademovic Tahirovic et al., 2025]. We therefore ask whether a model of reactions can, for every value of its weights, guarantee products with valid valences and bond changes accounting for the observed change exactly, and whether this guarantee increases or decreases accuracy.

Approach. Discrete, continuous, and stochastic nets, the three semantics of a net, only differ in their rate law, which is the propensity of a transition to fire given the tokens on its input places, and share the firing form, the enabling rule, and locality. Therefore, Neural Petri Flow (NPF) only learns the rate law, or a readout for classification, and computes the rest without trainable parameters. Atom mapping solves the state equation for the firing vector that forms or breaks the fewest bonds without learned weights, and gives the forward model its training target. For forward prediction, NPF plays a token game in which it fires one bond change at a time with the learned rate law choosing each move (Figure 1). For chemistry, the rate law reads the whole marking and as the token game fires one bond change at a time, non-negativity still requires the enabling rule, which is imposed as a mask (Section 4). With electrons as tokens, the same token game predicts the elementary steps of reaction mechanisms (Section 5).

More than a Petri net in name only. To avoid introducing a generic neural network that is a Petri net in name only, we support every Petri component of the valence net that carries a guarantee with a proof, a reason no neural network without the Petri net can do the same, a numerical check, and every component except conservation with a comparison to a generic network of equal size. For the valence rule, we prove that, for every value of its weights, the token game never gives a carbon with a valence budget of four a fifth bond (Proposition 4), and that the rule removes orders of bond changes but never a product within the valence budgets (Lemma 2. With untrained weights, no marking that the token game visits breaks the rule by more than half a token (Appendix D.5). Graph-edit and electron-flow models also change one bond or electron pair at a time, however, most fix or learn an order of edits [Do et al., 2019, Sacha et al., 2021], learn the valence rule, as FlowER does [Joung et al., 2025], or check only that the giving site has electrons, and not that

A PREPRINT

the receiving atom has room, as in MAELLE [Xuan-Vu et al., 2026]. In NPF, the valence rule holds at every step for every weight, and the state equation makes the order irrelevant.