Petri-Net Safety Shield for Neural Policies
Implementation & benchmark of arXiv:2607.22062 — Constraint-Driven Synthesis of Hyper Petri Nets
Source paper: Constraint-Driven Synthesis of Hyper Petri Nets arXiv:2607.22062 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Compile Boolean safety requirements over a discrete plant state into a Petri Net and place a transition mask between a neural policy and the environment. The policy may score all candidate actions, but only transitions enabled at the current marking are executable; this prevents invariant-violating actions and exposes deadlocks or unreachable policy proposals explicitly.
Formulas
Mathematical statement
A Hyper Petri Net is \(HyPN=(P,T,F,W,M_{0},\mathcal{M}^{obs})\), where \(P\) is the set of places, \(T\) the transitions, \(F\) the input and output arcs, \(W(p,t)\) their nonnegative weights, \(M_{0}\) the initial marking, and \(\mathcal{M}^{obs}\subseteq\mathcal{R}(M_{0})\) the observable reachable markings. A transition \(t\) is enabled at marking \(M\) when \(M(p)\ge W(p,t)\) for every input place \(p\in{}^{\bullet}t\). Firing produces \(M'=fire(t,M)\). The shield exposes only transitions satisfying this enabledness test and whose successor remains in \(\mathcal{M}^{obs}\). If the current marking is admissible and the shield executes only enabled transitions whose successors are admissible, induction gives \(M_k\in\mathcal{M}^{obs}\) for every executed step \(k\).
Implementation notes
First, use this as the final action-selection layer of a discrete-action RL controller, neural task planner, or mixture-of-experts router whose experts correspond to Petri-Net transitions. Maintain the marking \(M\) from the observed Boolean plant state; do not infer it only from the policy hidden state unless a separately verified state estimator is available. Construct places for each Boolean variable and resource token, compile each invariant \(C_j(x)\) into an admissibility check, and precompute reachable markings with breadth-first search for a small prototype. At every environment step, compute policy logits \(z=f_\theta(o)\), enumerate transitions \(t\), evaluate \(enabled(t,M)\), calculate \(M_t=fire(t,M)\), reject \(t\) if any \(C_j(M_t)=0\), and set rejected logits to \(-\infty\). Sample or select from the remaining logits, execute the transition, and update \(M\leftarrow M_t\). If no transition is enabled, emit a distinguished deadlock action and log the violated precondition rather than selecting an unsafe action. Enabledness, firing, invariant satisfaction, and reachability are exact symbolic computations for a finite Boolean net; policy quality, observation errors, and deadlock frequency are measured empirically. For large nets, use bounded search or a conservative reachable-state cache, but retain direct invariant checks. The first experiment should use PPO on a grid-world rover task with battery, antenna, motion, and mutually exclusive mode variables. Compare an unshielded MLP, a penalty-trained policy, and the shielded policy. The quantitative prediction is zero post-shield invariant violations under exact observations across at least 10,000 episodes. Invalid but locally plausible actions whose successors are unreachable must be rejected, and the rejected-action rate should decrease during training. Every deadlock should be exactly reproducible from the same marking.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Confirmed ✓
Stage 2 · Practical benchmark result: No measurable effect
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 9/10
Built an exact finite Petri-net transition shield with enabledness, firing, BFS-derived admissible markings, successor filtering, and deadlock accounting. The mechanism manifested: all accepted successors were safe, shielded violations were 0 over 10,000 episodes, and the uniform rejection sweep matched P(reject)=1-k/n with maximum absolute error 0.0068. This is a clear safety win, though the fixed toy policy achieved no task successes and PPO or learning efficiency was not tested.
- Agent confidence
- 9/10
- Baseline
- 10,000/10,000 episodes violated safety; 0 successes
- Idea
- 0/10,000 safety violations; 400,000 rejected proposals over 400,000 shielded steps; 0 successes; rejection-law maximum absolute error 0.0068; closure violations 0
Limitations: The prototype uses a small one-hot rover marking and fixed random linear logits rather than PPO or a trained neural policy. It does not measure runtime, reward improvement, observation noise, large-net scaling, or compare against penalty training; the toy task also produced no successful episodes.
How to run: python3 petri_shield_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.22062)
Ahead of the baseline (−0.0%) but not statistically significant (p=0.9851, wins 4 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0014
- Idea mean
- 0.0014
- Effect (Δ)
- -0 (−0.0%; negative = idea better)
- Wins
- 4 / 8 paired seeds
- p-value
- 0.9851 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±7.6%
- Mechanism
- Confirmed ✓
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
The built-in dynamics task is supervised pendulum next-state prediction rather than interactive RL, so action safety was approximated by filtering observed control inputs. Long-horizon closed-loop safety, observation noise, online policy optimization, and larger Petri nets were not tested.
How to run: python3 petri_bench.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 9/10
The Petri-style successor shield was evaluated on the registered dynamics/rnn_small benchmark with identical architecture, data, epochs, and learning-rate union. The closure check observed zero accepted unsafe successors, but the task metric showed no significant improvement: paired delta -5.28e-7 and permutation p=0.98515, so the idea does not count as a benchmark win.
- Baseline
- best_cfg {lr: 0.01, epochs: 12}; full 8-seed test MSE mean 0.001394080012687482, std 0.0003941947646392458
- Idea
- best_cfg {lr: 0.01, epochs: 12}; full 8-seed test MSE mean 0.0013935517708887346, std 0.0003435936282481101; paired delta -5.282417987473309e-07; p=0.98515
Benchmark result
Ahead of the baseline (−0.0%) but not statistically significant (p=0.9851, wins 4 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0014
- Idea mean
- 0.0014
- Effect (Δ)
- -0 (−0.0%; negative = idea better)
- Wins
- 4 / 8 paired seeds
- p-value
- 0.9851 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±7.6%
- Mechanism
- Confirmed ✓
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
The built-in dynamics task is supervised pendulum next-state prediction rather than interactive RL, so action safety was approximated by filtering observed control inputs. Long-horizon closed-loop safety, observation noise, online policy optimization, and larger Petri nets were not tested.
How to run: python3 petri_bench.py
Artifacts
- bench_report.json 6.0 KB View Raw
- petri_bench.py 4.7 KB View Raw
- petri_shield_experiment.py 5.7 KB View Raw
- report.md 1.3 KB View
- report_bench_2026-08-31T161516.md 4.3 KB View
- results.json 5.1 KB View Raw