omnibias.core.verified.sigma
Coefficient recurrences, activation contracts, jet algebra, and verified arithmetic shared by the numerical backends.
import omnibias.core.verified.sigmaModule contract & mathematical conventions
Rigorous interval enclosure of the closed-form derivative tower.
This is the verified twin of omnibias's float fastpath kernels: it returns a
guaranteed enclosure of sigma^(k)(z) for k = 0 .. order given an interval
enclosure of the argument z. The same closed-form structure used everywhere
in omnibias is reused -- a single transcendental evaluation
(omnibias.core.verified.transcend) followed by exact-integer polynomial
evaluation (omnibias.core.verified.coeffs.horner_interval) -- so the
enclosure is tight and needs only **one** transcendental enclosure regardless of
the derivative order.
Supported activations: "tanh", "sigmoid", "gaussian"
(g(z) = exp(-z^2 / 2)), the trigonometric pair "sin" / "cos", the
smooth closed-form neural activations "silu" (z * sigmoid(z)), "gelu"
(exact z * Phi(z)), and "softplus" (ln(1 + e^z)), and "sech"
(1 / cosh(z), the secant / Euler-number tower sech^(n) = Q_n(tanh) sech).
The neural three reuse the sigmoid / Gaussian towers via the product / shift
identities (see the helper docstrings below), so they need no new polynomial
recurrence.
The trigonometric tower is closed form to *every* order with **no** polynomial
recurrence: cos and sin are their own fourth derivatives, so the whole
tower is the 4-cycle of phase shifts (cos, -sin, -cos, sin) /
(sin, cos, -sin, -cos) built from two interval enclosures
(~omnibias.core.verified.transcend.cos_iv and sin_iv) regardless of
order. This admits classical Fourier-mode / plane-wave exact solutions to the
certified jet.
Shared formulas do not imply universal floating-point identity. Verify dtype, shape, derivative-order support, and the stated numerical assumptions for the path you use.
sigma_tower_interval
omnibias.core.verified.sigma_tower_intervalSource ↗sigma_tower_interval(name: str, z: Interval, order: int) -> tuple[Interval, ...]Enclose (sigma(z), sigma'(z), ..., sigma^(order)(z)) over interval z.
Parameters
name One of "tanh", "sigmoid", "gaussian", "sin", "cos", "silu", "gelu" (exact), "softplus", or "sech".
z Interval enclosure of the scalar argument.
order Highest derivative order N; the tower has N + 1 entries.
Parameters
| Name | Type & default | Contract |
|---|---|---|
namepositional-or-keyword | strRequired | One of "tanh", "sigmoid", "gaussian", "sin", "cos", "silu", "gelu" (exact), "softplus", or "sech". |
zpositional-or-keyword | IntervalRequired | Interval enclosure of the scalar argument. |
orderpositional-or-keyword | intRequired | Highest derivative order N; the tower has N + 1 entries. |
tuple[Interval, ...]Explicit validation & failure cases
- When
order < 0, raisesValueError(f'order must be >= 0, got {order}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · g2 non vacuous
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_g2_non_vacuous() -> None:
ex = worked_example()
assert float(ex["remainder_width"]) < 0.1
assert ex["vacuous"] is False
assert float(ex["width"]) < 0.1python -m pytest "packages/omnibias-core/tests/verified/test_tm_neuron.py::test_g2_non_vacuous" -qRegression example · trig tower is four periodic
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_trig_tower_is_four_periodic() -> None:
# f^(k) == f^(k+4): the enclosures must coincide structurally.
z = Interval(0.2, 0.6)
for name in ("sin", "cos"):
tower = sigma_tower_interval(name, z, 8)
for k in range(5):
assert tower[k] == tower[k + 4]python -m pytest packages/omnibias-core/tests/verified/test_verified_trig.py -k test_trig_tower_is_four_periodic -qRead the implementation
def sigma_tower_interval(name: str, z: Interval, order: int) -> tuple[Interval, ...]:
"""Enclose ``(sigma(z), sigma'(z), ..., sigma^(order)(z))`` over interval ``z``.
Parameters
----------
name
One of ``"tanh"``, ``"sigmoid"``, ``"gaussian"``, ``"sin"``, ``"cos"``,
``"silu"``, ``"gelu"`` (exact), ``"softplus"``, or ``"sech"``.
z
Interval enclosure of the scalar argument.
order
Highest derivative order ``N``; the tower has ``N + 1`` entries.
"""
if order < 0:
raise ValueError(f"order must be >= 0, got {order}")
if name == "tanh":
t = tanh_iv(z)
return tuple(
horner_interval(tanh_poly_coeffs_exact(k), t) for k in range(order + 1)
)
if name == "sech":
t = tanh_iv(z)
sech = sech_iv(z)
return tuple(
horner_interval(sech_poly_coeffs_exact(k), t) * sech for k in range(order + 1)
)
if name == "sigmoid":
return tuple(_sigmoid_tower(z, order))
if name == "silu":
return _silu_tower(z, order)
if name == "softplus":
return _softplus_tower(z, order)
if name == "gelu":
return _gelu_tower(z, order)
if name == "gaussian":
return _gaussian_tower(z, order)
if name in ("sin", "cos"):
return _trig_tower(name, z, order)
raise ValueError(f"unsupported activation {name!r}; expected one of {_SUPPORTED}")Other public import paths
omnibias.core.verified.sigma_tower_intervalomnibias.core.verified.sigma.sigma_tower_interval
sigma_value_interval
omnibias.core.verified.sigma_value_intervalSource ↗sigma_value_interval(name: str, z: Interval) -> IntervalEnclosure of sigma(z) (the zeroth tower entry).
Parameters
| Name | Type & default | Contract |
|---|---|---|
namepositional-or-keyword | strRequired | See the operation contract and implementation below. |
zpositional-or-keyword | IntervalRequired | See the operation contract and implementation below. |
IntervalExecuted regression · g2 non vacuous
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_g2_non_vacuous() -> None:
ex = worked_example()
assert float(ex["remainder_width"]) < 0.1
assert ex["vacuous"] is False
assert float(ex["width"]) < 0.1python -m pytest "packages/omnibias-core/tests/verified/test_tm_neuron.py::test_g2_non_vacuous" -qRead the implementation
def sigma_value_interval(name: str, z: Interval) -> Interval:
"""Enclosure of ``sigma(z)`` (the zeroth tower entry)."""
return sigma_tower_interval(name, z, 0)[0]Other public import paths
omnibias.core.verified.sigma_value_intervalomnibias.core.verified.sigma.sigma_value_interval