# Petri-Net Safety Shield for Neural Policies

- ID: 1262
- Canonical URL: https://synthcore.org/idea/1262/petri-net-safety-shield-for-neural-policies
- API JSON: https://synthcore.org/api/idea/1262.json
- API Markdown: https://synthcore.org/api/idea/1262.md
- Verification status: mech_ok_no_baseline
- Source: [arXiv:2607.22062](https://arxiv.org/abs/2607.22062)
- Category: architecture
- Solves: stability, accuracy, generalization
- ML areas: rl, moe-routing
- Math tags: control-theory, dynamical-systems, combinatorics, graph-theory
- Ratings: usefulness 7/10; difficulty 5/10; novelty 5/10

## 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.

## 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\).

## Key formulas

- $$HyPN=(P,T,F,W,M_0,\mathcal{M}^{obs}),\qquad \mathcal{M}^{obs}\subseteq\mathcal{R}(M_0).$$
- $$enabled(t,M)\Longleftrightarrow \forall p\in{}^{\bullet}t:\ M(p)\ge W(p,t),\qquad M\xrightarrow{t}M'=fire(t,M).$$
- $$\pi_{shield}(t\mid M)=\frac{\exp z_t}{\sum_{u\in A(M)}\exp z_u}\mathbf{1}[t\in A(M)],\qquad A(M)=\{t\in T:enabled(t,M)\land fire(t,M)\in\mathcal{M}^{obs}\}.$$

## 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

- Status: mech_ok_no_baseline
- Mechanism evidence: yes
- Mechanism confirmed: yes
- Practical verdict: no_effect
- Verdict: 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.

### Mechanism check

- Verdict: 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.
- Confidence: 9/10
- 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.

### Practical benchmark

- Paired seeds: 8
- Baseline mean: 0
- Idea mean: 0
- p-value: 0.98515
- Paired wins: 4/8
- Benchmark verdict: no measurable effect

## Artifacts

- [bench_report.json](https://synthcore.org/code/504/bench_report.json)
- [petri_bench.py](https://synthcore.org/code/504/petri_bench.py)
- [petri_shield_experiment.py](https://synthcore.org/code/504/petri_shield_experiment.py)
- [report.md](https://synthcore.org/code/504/report.md)
- [report_bench_2026-08-31T161516.md](https://synthcore.org/code/504/report_bench_2026-08-31T161516.md)
- [results.json](https://synthcore.org/code/504/results.json)
- [Download all files as ZIP](https://synthcore.org/download/504)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
