High-Order Barrier Recurrent Cell
Implementation & benchmark of arXiv:2607.17032 — Optimal Safety Control using High-Order Control Barrier Functions
Source paper: Optimal Safety Control using High-Order Control Barrier Functions arXiv:2607.17032 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Replace an unconstrained recurrent update or neural-ODE vector field with a nominal learned control plus an explicit high-order barrier correction. The correction enforces hidden-state safety even when the control affects the safety variable only after several time derivatives. A quadratic-program projection preserves the nominal network output whenever the learned dynamics already satisfy the barrier inequality.
Formulas
Mathematical statement
Let the hidden state obey $\dot{x}=f_\theta(x,z)+g_\theta(x,z)u$, where $z$ is the input and $u$ is a learned control. Define the safe set $\mathcal C_0=\{x:h(x)\ge0\}$. For relative degree $p$, recursively define $\psi_0=h$ and $\psi_i=L_f\psi_{i-1}+\alpha_i(\psi_{i-1})$, where $L_f$ is the Lie derivative along $f$, $L_g$ is the Lie derivative along $g$, and each $\alpha_i$ is an increasing class-$\mathcal K$ function. Enforce $L_f\psi_{p-1}+L_g\psi_{p-1}u+\alpha_p(\psi_{p-1})\ge0$. Writing $a=L_f\psi_{p-1}$ and $b=L_g\psi_{p-1}$, the minimum-change controller solves a quadratic projection. The paper's smooth completion-of-squares feedback is $\kappa(a,b)=-(a+\sqrt{a^2+\|b\|^4})b^\top/\|b\|^2$, regularized numerically near $b=0$.
Implementation notes
1. Exact integration point: use a second-order recurrent or state-space cell with state $x=(q,v)$ and nominal learned acceleration $u_{\mathrm{nom}}=\pi_\theta(x,z)$. Choose $h(x)=1-\|x\|^2/R^2$ to bound hidden activations, or $h(x)=r^2-\|q\|^2$ for a position-like latent state. 2. Pseudocode: compute $\psi_0=h$; for $i=1$ through $p-1$, compute $\psi_i=J_{\psi_{i-1}}f+\alpha_i(\psi_{i-1})$ using automatic differentiation; compute $a=J_{\psi_{p-1}}f$ and $b=J_{\psi_{p-1}}g$; set $c=a+b u_{\mathrm{nom}}+\alpha_p(\psi_{p-1})$; apply $u=u_{\mathrm{nom}}+\max(0,-c/(\|b\|^2+\varepsilon))b^\top$. Advance the cell with Euler or RK2 and backpropagate through the nominal network. 3. Computed from the paper: the recursive barrier variables and terminal inequality. Estimated empirically: Lie derivatives, relative degree, and regions where $\|b\|$ is small. 4. First experiment: compare a GRU, spectral-normalized GRU, and HOCBF-GRU on sequential MNIST with equal parameter counts. Use $p=2$, $h=1-\|x\|^2/R^2$, and perturb inputs to induce hidden-state growth. The quantitative prediction is forward invariance: trajectories initialized with $\psi_0,\psi_1\ge0$ should maintain $h\ge0$ up to numerical error, while the unconstrained GRU should cross $h=0$. The transition should occur when the measured terminal margin $a+b u+\alpha_2(\psi_1)$ changes from negative to nonnegative; after that point, at least 95 percent of violations should disappear.
Verification
Stage 1 · Toy mechanism gate: Failed ✗
Stage 2 · Mechanism transferred to benchmark: Not tested
Stage 2 · Practical benchmark result: Not run
Methodology: Toy-system gate first; the benchmark stage runs only after a pass. How verification works
Stage 1 — Mechanism check agent confidence 10/10
Built and numerically tested a relative-degree-2 HOCBF controller for q_dot=v, v_dot=u with h=1-q^2, including exact minimum-change projection and forcing/timestep sweeps. The QP projection behaved as predicted: nominally feasible inputs had zero correction, active constraints had terminal-margin residual below 1.6e-8, and barrier trajectories had zero sampled violations while the baseline diverged strongly. However, the stated smooth kappa formula was feasible in 0/10000 random tests for the stated >=0 inequality, so the overall idea fails the required math-mechanism check despite the corrected projection working.
- Agent confidence
- 10/10
- Baseline
- For forcing A=1..8, minimum h=-30.28,-106.86,-397.83,-872.57,-1531.06; violation fractions=0.799,0.856,0.897,0.915,0.927.
- Idea
- Exact projection: zero-correction error 0, active terminal-equality error <=1.57e-8; barrier minimum h remained 0.00627..0.00856 with zero violations across A=1..8. Active fraction rose from 0 at A=0 to 1 at A>=1, with predicted initial threshold A=0.9. Stated smooth kappa feasibility was 0/10000.
Limitations: This is a toy second-order plant, not a trained GRU, neural ODE, or sequential-MNIST experiment. It uses small-step midpoint integration, scalar control, fixed barrier gains, and does not test learning accuracy, parameter matching, multidimensional g, runtime, or a corrected-sign version of the smooth feedback.
How to run: python3 hocbf_experiment.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Artifacts
- hocbf_experiment.py 4.6 KB View Raw
- report.md 1.7 KB View
- results.json 4.0 KB View Raw