Skip to main content

omnibias.boolean.jax.ops.spectrum

0.1.0a2AlphaPython >=3.10Apache-2.0

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

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

Differentiable Boolean spectrum engine (jax) via multivariate jets.

Bit-identical twin of omnibias.boolean.torch.ops.spectrum (double precision required for exact cross-backend parity -- enable jax_enable_x64). The multilinear extension is built as a multivariate jet with omnibias.jax.jet_mv.identity_jet and the truncated Cauchy product, and the Mobius / Walsh spectra are read off with omnibias.jax.jet_mv.jet_partials.

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

algebraic_degree_soft​

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

Spectral-energy-weighted mean monomial order (a smooth degree proxy).

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
ReturnsArray
Read the implementation
def algebraic_degree_soft(values: Sequence[float] | Array) -> Array:
    """Spectral-energy-weighted mean monomial order (a smooth degree proxy)."""
    w = walsh_coeffs(values)
    n = _num_vars(w.shape[0])
    orders = jnp.asarray(
        [bin(mask).count("1") for mask in range(1 << n)], dtype=w.dtype
    )
    energy = (w**2).sum()
    return (orders * w**2).sum() / energy
Other public import paths
  • omnibias.boolean.jax.ops.algebraic_degree_soft
  • omnibias.boolean.jax.ops.spectrum.algebraic_degree_soft
FUNCTION

influences_diff​

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

Per-coordinate influence Inf_i = sum_{S in i} hat f(S)^2 (differentiable).

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
ReturnsArray
Executed regression · walsh and influence 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_walsh_and_influence_parity() -> None:
    for tt in _tts(22):
        vals = pm1_values(tt)
        tw = _np(tb.walsh_coeffs(torch.tensor(vals, dtype=torch.float64)))
        jw = _np(jb.walsh_coeffs(jnp.asarray(vals, dtype=jnp.float64)))
        assert np.allclose(tw, jw, rtol=1e-9, atol=1e-11)
        ti = _np(tb.influences_diff(torch.tensor(vals, dtype=torch.float64)))
        ji = _np(jb.influences_diff(jnp.asarray(vals, dtype=jnp.float64)))
        assert np.allclose(ti, ji, rtol=1e-9, atol=1e-11)
python -m pytest "packages/omnibias-boolean/tests/test_cross_backend.py::test_walsh_and_influence_parity" -q
Read the implementation
def influences_diff(values: Sequence[float] | Array) -> Array:
    """Per-coordinate influence ``Inf_i = sum_{S in i} hat f(S)^2`` (differentiable)."""
    w = walsh_coeffs(values)
    n = _num_vars(w.shape[0])
    out = []
    for i in range(n):
        idx = [mask for mask in range(1 << n) if (mask >> i) & 1]
        out.append((w[jnp.asarray(idx)] ** 2).sum())
    return jnp.stack(out)
Other public import paths
  • omnibias.boolean.jax.ops.influences_diff
  • omnibias.boolean.jax.ops.spectrum.influences_diff
FUNCTION

mobius_coeffs​

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

{0,1} Mobius / multilinear coefficients m_S (indexed by subset mask).

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
ReturnsArray
Executed regression · mobius 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_mobius_parity() -> None:
    for tt in _tts(21):
        t = _np(tb.mobius_coeffs(torch.tensor(tt, dtype=torch.float64)))
        j = _np(jb.mobius_coeffs(jnp.asarray(tt, dtype=jnp.float64)))
        assert np.allclose(t, j, rtol=1e-9, atol=1e-11)
python -m pytest "packages/omnibias-boolean/tests/test_cross_backend.py::test_mobius_parity" -q
Read the implementation
def mobius_coeffs(values: Sequence[float] | Array) -> Array:
    """``{0,1}`` Mobius / multilinear coefficients ``m_S`` (indexed by subset mask)."""
    return _coeffs_vector(_as_array(values), "mobius")
Other public import paths
  • omnibias.boolean.jax.ops.mobius_coeffs
  • omnibias.boolean.jax.ops.spectrum.mobius_coeffs
FUNCTION

mobius_spectrum​

omnibias.boolean.jax.ops.mobius_spectrumSource ↗
mobius_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]

Mobius coefficients as a {variable-set: m_S} mapping.

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
Returnsdict[frozenset[int], Array]
Read the implementation
def mobius_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]:
    """Mobius coefficients as a ``{variable-set: m_S}`` mapping."""
    return _to_spectrum(mobius_coeffs(values))
Other public import paths
  • omnibias.boolean.jax.ops.mobius_spectrum
  • omnibias.boolean.jax.ops.spectrum.mobius_spectrum
FUNCTION

walsh_coeffs​

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

{+-1} Walsh / Fourier coefficients hat f(S) (indexed by subset mask).

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
Regression example · walsh and influence parity

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_walsh_and_influence_parity() -> None:
    for tt in _tts(22):
        vals = pm1_values(tt)
        tw = _np(tb.walsh_coeffs(torch.tensor(vals, dtype=torch.float64)))
        jw = _np(jb.walsh_coeffs(jnp.asarray(vals, dtype=jnp.float64)))
        assert np.allclose(tw, jw, rtol=1e-9, atol=1e-11)
        ti = _np(tb.influences_diff(torch.tensor(vals, dtype=torch.float64)))
        ji = _np(jb.influences_diff(jnp.asarray(vals, dtype=jnp.float64)))
        assert np.allclose(ti, ji, rtol=1e-9, atol=1e-11)
python -m pytest packages/omnibias-boolean/tests/test_cross_backend.py -k test_walsh_and_influence_parity -q
Read the implementation
def walsh_coeffs(values: Sequence[float] | Array) -> Array:
    """``{+-1}`` Walsh / Fourier coefficients ``hat f(S)`` (indexed by subset mask)."""
    return _coeffs_vector(_as_array(values), "walsh")
Other public import paths
  • omnibias.boolean.jax.ops.walsh_coeffs
  • omnibias.boolean.jax.ops.spectrum.walsh_coeffs
FUNCTION

walsh_spectrum​

omnibias.boolean.jax.ops.walsh_spectrumSource ↗
walsh_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]

Walsh/Fourier coefficients as a {variable-set: hat f(S)} mapping.

Parameters

NameType & defaultContract
valuespositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
Returnsdict[frozenset[int], Array]
Read the implementation
def walsh_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]:
    """Walsh/Fourier coefficients as a ``{variable-set: hat f(S)}`` mapping."""
    return _to_spectrum(walsh_coeffs(values))
Other public import paths
  • omnibias.boolean.jax.ops.walsh_spectrum
  • omnibias.boolean.jax.ops.spectrum.walsh_spectrum