← Home
petri-net ode equivalence go-pflow petri-pilot

Comparing Nets by Their ODE Signatures

When we run a Petri net through the ODE solver, each place gets a trajectory — a curve of token concentration evolving through continuous time. The collection of all those curves is the ODE solution. Two nets that produce the same solution encode the same system, regardless of what their places are called.

In tic-tac-toe, we can see this directly. The heatmap view picks each board position — a place in the net — and shows its ODE score as a color:

Empty Board Heatmap

Center scores 1.27. Corners score 0.95. Edges score 0.63. No game heuristics — this pattern comes from the net's topology. Each cell is a place, and the color is the ODE solution at that place, projected through the scoring function win_x - win_o. These floats are proportional to the integers 4, 3, 2 — the incidence degrees to terminal win transitions.

The tic-tac-toe model exists in two forms: a Go struct with places named p00, x00, winX, and a JSON-LD file from pflow.xyz with places named P00, _X00, win_x. Different labels, same topology — 30 places, 34 transitions, 118 arcs. Both produce the same heatmap. Both produce the same ODE solution.

One Place at a Time

The comparison works by looking at one place at a time. For each place, we extract its trajectory from the ODE solution and compress it into a fingerprint:

type TrajectoryFingerprint struct {
    Name    string
    Initial float64
    Final   float64
    Max     float64
    Min     float64
    Mean    float64
    Samples []float64 // values at 10 fixed time points
}

This captures how the place evolves — whether it decays, grows, or reaches equilibrium, and at what rate. If place p00 in net A and place P00 in net B trace the same curve, their fingerprints will be nearly identical.

The heatmap already shows this. Corners all score 0.95 because the four corner places trace identical ODE curves — same initial token, same connectivity, same dynamics. Edges all score 0.63 for the same reason. The fingerprint distance formalizes what the heatmap color already reveals: places with the same ODE behavior match, regardless of name.

Discovering Correspondence

We can automate this. Run both nets through the ODE solver, compute fingerprints for every place, then pair them by distance:

result := petri.DiscoverMappingByTrajectory(
    netA, ratesA,
    netB, ratesB,
    [2]float64{0, 5.0},
)
// result.PlaceMappings: {"winX": ["win_x"], "next": ["Next"], ...}
// result.Confidence: 0.87
// result.Ambiguous: ["p01", "p10", ...] (symmetric places)

Places with unique trajectories — winX, next, the history places — match cleanly. Symmetric places like the nine board positions produce ties, because their ODE curves are indistinguishable. The algorithm reports these as ambiguous rather than guessing.

ODE Signature Pipeline

Proving Equivalence

With a mapping in hand, we compare mapped places at multiple time points along the ODE solution:

result := petri.VerifyBehavioralEquivalence(
    netA, ratesA, netB, ratesB, mapping,
    &petri.BehavioralOptions{
        Tspan:     [2]float64{0, 10.0},
        Tolerance: 1e-6,
        SampleAt:  []float64{1.0, 2.0, 3.0, 5.0, 7.0, 10.0},
    },
)
// result.Equivalent: true
// result.MaxDifference: 0.000000

The go-pflow test suite runs this on tic-tac-toe: the Go struct and the pflow.xyz JSON-LD produce identical trajectories at every sample point. It shuffles the model 100 times — randomizing the order of places, transitions, and arcs — and equivalence holds every time. The ODE solution doesn't care about serialization order. Remove one arc and the solution changes.

Same Solution, Different Views

petri-pilot generates applications from Petri net models. When prediction.enabled: true, it generates ODE code using the same go-pflow solver. For the coffee shop model, the view is a resource depletion chart — each resource place traced over 8 hours. For tic-tac-toe, it's the heatmap — each board position colored by its ODE score. Different projections of the same kind of solution.

The model written in pflow.xyz, the code generated by petri-pilot, and the Go struct in go-pflow all produce the same ODE solution. If the trajectories match place by place, the representations are interchangeable.

This topic is covered in depth in Chapter 3: From Discrete to Continuous and Chapter 18: Dual Implementation of Petri Nets as a Universal Abstraction.

×

Follow on Mastodon