From discrete tokens to continuous differential equations — and why the structure of a net tells you more than you'd expect.
Every Petri net can be executed in two fundamentally different ways:
Fire one transition at a time. Tokens move as integers. This is what the interactive demos do when you click buttons.
Treat token counts as real numbers and let them flow continuously. Transitions fire at rates proportional to their inputs. This produces smooth curves over time.
The continuous version turns any Petri net into a system of ordinary differential equations (ODEs). You've seen ODEs before if you've studied physics or population biology — they describe how quantities change over time.
The rule for converting a Petri net to ODEs comes from chemistry, where it's called mass-action kinetics:
The rate of a reaction is proportional to the product of its reactant concentrations.
In Petri net terms: the firing rate of a transition equals its rate constant k multiplied by the token count in each of its input places.
For a transition with rate k and two input places with token counts x and y:
Each place's token count changes based on the transitions connected to it:
This is exactly how chemical kinetics works, which is why Petri nets model chemistry so naturally. But the same math works for any system with competing flows.
The Predator-Prey demo has just two places (prey, predator) and three transitions:
prey_reproduce (rate 1.0): prey → 2× preypredation (rate 0.01): prey + predator → 2× predatorpredator_death (rate 0.6): predator → (nothing)The ODE system is:
These are the Lotka-Volterra equations — one of the most famous ODE systems in ecology. We didn't write them by hand. They emerged automatically from the Petri net structure.
See the population oscillations →This is where it gets surprising. The Tic-Tac-Toe demo has 34 places and 36 transitions. The ODE simulation doesn't "play" the game. Instead, it reveals the strategic value of each cell.
Here's why it works:
The center cell participates in 4 win patterns (2 diagonals, 1 row, 1 column). Corner cells participate in 3. Edge cells participate in 2. The ODE solver discovers this automatically — the center cell accumulates the highest token flow.
No game tree search. No minimax algorithm. The topology of the net — which places connect to which transitions — encodes the strategic structure. The ODE solver just reads it out.
Watch the ODE reveal strategy →This same technique works across every ODE demo on this site:
In every case, you define the structure (places, transitions, arcs, rates) and the ODE solver reveals the behavior (curves, equilibria, oscillations, bottlenecks).
Most simulation tools require you to write equations by hand. With Petri nets:
Key insight: A Petri net is not just a diagram. It's a mathematical object that simultaneously defines a discrete state machine, a continuous dynamical system, and the structure of a generated application (API, database, event log). One model, three interpretations.
Open any model in the Petri Net Viewer and click the play button (▶) to run the ODE simulation. You'll see token counts evolve as smooth curves. Adjust transition rates and initial token counts to explore different scenarios.
Open the Petri Net Viewer →