# Scaled Reciprocal Safety Layer

- ID: 2689
- Canonical URL: https://synthcore.org/idea/2689/scaled-reciprocal-safety-layer
- API JSON: https://synthcore.org/api/idea/2689.json
- API Markdown: https://synthcore.org/api/idea/2689.md
- Verification status: unverified
- Source: [arXiv:2608.22633](https://arxiv.org/abs/2608.22633)
- Category: dynamics
- Solves: stability, accuracy, generalization
- ML areas: training, regularization, rl, optimizer
- Math tags: control-theory, dynamical-systems, optimization, differential-geometry
- Ratings: usefulness 6/10; difficulty 5/10; novelty 8/10

## Idea description

For a learned control-affine latent dynamics model, replace the ordinary reciprocal barrier 1/h₀(z) with B(z) = s(z)/h₀(z), where h₀ is the physical safety margin and s is positive but depends on a velocity-like quantity whose derivative is directly affected by the action. This preserves the singularity at h₀ = 0 while giving the policy or safety projection layer first-order action authority over the barrier derivative.

## Mathematical statement

Let the learned or known dynamics be ż = f(z) + g(z)a, with state z, action a, drift f, and input matrix g. Let the physical safe set be C₀ = {z : h₀(z) ≥ 0}, and assume Lᵍh₀(z) = ∇h₀(z)ᵀg(z) = 0, so the original margin has relative degree two. Define q(z) = Lᶠh₀(z) = ∇h₀(z)ᵀf(z), and choose s(z) = 1 + δ tanh(κq(z)), where 0 < δ < 1 and κ > 0. Then s(z) > 0 everywhere and B(z) = s(z)/h₀(z) is defined on the interior h₀ > 0 and diverges as h₀ approaches zero from above. Since Lᵍh₀ = 0, LᵍB = Lᵍs/h₀, with Lᵍs = δκ sech²(κq)Lᵍq. Thus LᵍB is generically nonzero even when Lᵍh₀ = 0, including near q = 0, where Lᵍs is approximately δκLᵍq. Enforce the reciprocal-barrier condition LᶠB + LᵍB a ≤ α(B), where α is an increasing extended class-K function such as α(B) = γB, to obtain a forward-invariance certificate under the model assumptions.

## Key formulas

- C₀ = {z : h₀(z) ≥ 0},   ż = f(z) + g(z)a,   Lᵍh₀ = ∇h₀(z)ᵀg(z) = 0.
- q(z) = Lᶠh₀(z),   s(z) = 1 + δ tanh(κq(z)),   B(z) = s(z)/h₀(z),   0 < δ < 1.
- LᵍB = Lᵍs/h₀ = δκ sech²(κq)Lᵍq/h₀,   Lᵍq = ∇q(z)ᵀg(z).
- LᶠB + LᵍB a ≤ α(B),   for example α(B) = γB with γ > 0.

## Implementation notes

1. Integration point: use this as a differentiable safety layer after a neural policy aπ = πφ(z), or as a regularizer during model-based reinforcement learning and neural-ODE training. The model must expose f(z) and g(z), either from known physics, a learned control-affine model, or local Jacobian estimates. Choose a differentiable safety margin h₀(z), such as squared distance to an obstacle minus a radius, an actuator-temperature margin, or a latent-state operating envelope. 2. Pseudocode: compute h = h₀(z), q = gradient(h) transpose f(z), s = 1 + δ tanh(κq), B = s/(h + ε), Lᵍq = gradient(q) transpose g(z), and LᵍB = δκ sech²(κq)Lᵍq/(h + ε). Compute LᶠB by automatic differentiation. Project aπ onto the smallest correction satisfying LᶠB + LᵍB a ≤ γB and action bounds; alternatively add λ max(0, LᶠB + LᵍB aπ − γB)² to the training loss. 3. Computed versus estimated: h, gradients, and Lie derivatives are computed by autodiff when f, g, and h₀ are available. Otherwise estimate f and g from short action-conditioned trajectories and validate derivative estimates with finite differences. Clip B only for numerical overflow, not near the evaluation boundary. 4. First cheap experiment: train a small MLP policy on a two-dimensional point-mass or unicycle obstacle-avoidance task using PPO or behavior cloning, comparing no barrier, ordinary 1/h₀, and the scaled barrier. Sweep action-step size and evaluate one-step constraint feasibility. The quantitative prediction is that ordinary 1/h₀ has LᵍB = 0 when Lᵍh₀ = 0, whereas the scaled barrier has LᵍB approximately equal to δκLᵍq/h₀ at q = 0. Measure the fraction of states where the safety projection is feasible and verify that the scaled method retains nonzero action authority near zero radial velocity. Under an accurately learned model, trajectories satisfying the inequality should show zero boundary crossings; robustness should degrade when derivative-estimation error exceeds the available slack γB − (LᶠB + LᵍB aπ).

## Disclaimer

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