Skip to main content

omnibias.boolean.jax.ops.design

0.1.0a2AlphaPython >=3.10Apache-2.0

Boolean truth tables, multilinear extensions, algebraic spectra, and finite-temperature gate systems.

import omnibias.boolean.jax.ops.design
Module contract & mathematical conventions

Differentiable Boolean-function design losses (jax).

Twin of omnibias.boolean.torch.ops.design: spectral objectives (degree_penalty, influence_penalty, target_spectrum_loss) built on the differentiable ~omnibias.boolean.jax.ops.spectrum engine.

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.

FUNCTION

degree_penalty​

omnibias.boolean.jax.ops.degree_penaltySource ↗
degree_penalty(values: Sequence[float] | Array) -> Array

sum_S |S| * hat f(S)^2 -- spectral energy weighted by monomial order.

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
ReturnsArray
Executed regression · design loss parity

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_design_loss_parity() -> None:
    vals = [0.1, 0.7, 0.3, 0.9]
    t = float(tb.degree_penalty(torch.tensor(vals, dtype=torch.float64)))
    j = float(jb.degree_penalty(jnp.asarray(vals, dtype=jnp.float64)))
    assert t == pytest.approx(j, rel=1e-9, abs=1e-11)
python -m pytest "packages/omnibias-boolean/tests/test_cross_backend.py::test_design_loss_parity" -q
Read the implementation
def degree_penalty(values: Sequence[float] | Array) -> Array:
    """``sum_S |S| * hat f(S)^2`` -- spectral energy weighted by monomial order."""
    w = walsh_coeffs(values)
    n = w.shape[0].bit_length() - 1
    orders = jnp.asarray(
        [bin(mask).count("1") for mask in range(1 << n)], dtype=w.dtype
    )
    return (orders * w**2).sum()
Other public import paths
  • omnibias.boolean.jax.ops.degree_penalty
  • omnibias.boolean.jax.ops.design.degree_penalty
FUNCTION

influence_penalty​

omnibias.boolean.jax.ops.influence_penaltySource ↗
influence_penalty(values: Sequence[float] | Array) -> Array

Total influence sum_i Inf_i (average sensitivity), differentiable.

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
ReturnsArray
Read the implementation
def influence_penalty(values: Sequence[float] | Array) -> Array:
    """Total influence ``sum_i Inf_i`` (average sensitivity), differentiable."""
    return influences_diff(values).sum()
Other public import paths
  • omnibias.boolean.jax.ops.influence_penalty
  • omnibias.boolean.jax.ops.design.influence_penalty
FUNCTION

target_spectrum_loss​

omnibias.boolean.jax.ops.target_spectrum_lossSource ↗
target_spectrum_loss(values: Sequence[float] | Array, target: Sequence[float] | Array, basis: str='walsh') -> Array

Mean-squared error between the function's spectrum and a target spectrum.

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
targetpositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
basispositional-or-keywordstrDefault: 'walsh'See the operation contract and implementation below.
ReturnsArray
Read the implementation
def target_spectrum_loss(
    values: Sequence[float] | Array,
    target: Sequence[float] | Array,
    basis: str = "walsh",
) -> Array:
    """Mean-squared error between the function's spectrum and a target spectrum."""
    if basis == "walsh":
        coeffs = walsh_coeffs(values)
    elif basis == "mobius":
        coeffs = mobius_coeffs(values)
    else:
        raise ValueError(f"basis must be 'walsh' or 'mobius', got {basis!r}")
    target_a = jnp.asarray(target, dtype=coeffs.dtype)
    return ((coeffs - target_a) ** 2).mean()
Other public import paths
  • omnibias.boolean.jax.ops.target_spectrum_loss
  • omnibias.boolean.jax.ops.design.target_spectrum_loss