boofun.core.representations.polynomial
Polynomial (ANF) representation for Boolean functions.
This module implements the Algebraic Normal Form (ANF) representation, where Boolean functions are represented as multivariate polynomials over GF(2).
Functions
|
Create constant polynomial. |
|
Create a single monomial from list of variable indices. |
|
Create polynomial for single variable. |
Classes
Polynomial (ANF) representation using coefficient dictionaries. |
- class boofun.core.representations.polynomial.PolynomialRepresentation[source]
Polynomial (ANF) representation using coefficient dictionaries.
Represents Boolean functions as polynomials over GF(2): f(x₁,…,xₙ) = ⊕ᵢ aᵢ ∏ⱼ∈Sᵢ xⱼ
Data format: Dict[frozenset, int] mapping subsets to coefficients
- evaluate(inputs: ndarray, data: Dict[frozenset, int], space: Space, n_vars: int) bool | ndarray[source]
Evaluate the polynomial at given inputs.
- Parameters:
inputs – Input values (integer indices or binary vectors)
data – Polynomial coefficients as {subset: coefficient}
space – Evaluation space
n_vars – Number of variables
- Returns:
Boolean result(s)
- dump(data: Dict[frozenset, int], space=None, **kwargs) Dict[str, Any][source]
Export polynomial in serializable format.
- Returns:
Dictionary with monomials and coefficients
- convert_from(source_repr: BooleanFunctionRepresentation, source_data: Any, space: Space, n_vars: int, **kwargs) Dict[frozenset, int][source]
Convert from any representation to polynomial using truth table method.
Uses the Möbius transform to compute ANF coefficients.
- convert_to(target_repr: BooleanFunctionRepresentation, source_data: Any, space: Space, n_vars: int, **kwargs) ndarray[source]
Convert from polynomial to another representation.
- create_empty(n_vars: int, **kwargs) Dict[frozenset, int][source]
Create empty polynomial (constant 0).
- is_complete(data: Dict[frozenset, int]) bool[source]
Check if polynomial has any non-zero coefficients.
- time_complexity_rank(n_vars: int) Dict[str, int][source]
Return time complexity for polynomial operations.
- get_storage_requirements(n_vars: int) Dict[str, int][source]
Return storage requirements for polynomial representation.
- get_degree(data: Dict[frozenset, int]) int[source]
Get the degree of the polynomial (size of largest monomial).
- get_monomials(data: Dict[frozenset, int]) List[frozenset][source]
Get all monomials with non-zero coefficients.
- boofun.core.representations.polynomial.create_monomial(variables: List[int]) Dict[frozenset, int][source]
Create a single monomial from list of variable indices.