boofun.core.representations.dnf_form
Disjunctive Normal Form (DNF) representation for Boolean functions.
DNF represents a Boolean function as a disjunction (OR) of conjunctions (AND) of literals (variables or their negations).
Example: f(x₁,x₂,x₃) = (x₁ ∧ ¬x₂) ∨ (¬x₁ ∧ x₂ ∧ x₃)
Functions
|
Create DNF from list of minterm indices. |
|
Convert DNF to CNF using distribution laws. |
|
Minimize DNF using Quine-McCluskey algorithm (simplified). |
Classes
|
DNF formula as a list of terms. |
DNF representation for Boolean functions. |
|
|
A single term (minterm) in DNF form. |
- class boofun.core.representations.dnf_form.DNFTerm(positive_vars: Set[int], negative_vars: Set[int])[source]
A single term (minterm) in DNF form.
- evaluate(x: List[int] | ndarray) bool[source]
Evaluate this DNF term.
- Parameters:
x – Binary input vector
- Returns:
Boolean result of this term
- class boofun.core.representations.dnf_form.DNFFormula(terms: List[DNFTerm], n_vars: int)[source]
DNF formula as a list of terms.
- terms
List of DNF terms
- Type:
- evaluate(x: List[int] | ndarray) bool[source]
Evaluate DNF formula.
- Parameters:
x – Binary input vector
- Returns:
Boolean result (OR of all terms)
- simplify() DNFFormula[source]
Simplify DNF by removing redundant terms.
- Returns:
Simplified DNF formula
- class boofun.core.representations.dnf_form.DNFRepresentation[source]
DNF representation for Boolean functions.
- evaluate(inputs: ndarray, data: DNFFormula, space: Space, n_vars: int) bool | ndarray[source]
Evaluate DNF representation.
- Parameters:
inputs – Input values (integer indices or binary vectors)
data – DNF formula
space – Evaluation space
n_vars – Number of variables
- Returns:
Boolean result(s)
- convert_from(source_repr: BooleanFunctionRepresentation, source_data: Any, space: Space, n_vars: int, **kwargs) DNFFormula[source]
Convert from another representation to DNF.
Uses truth table method to generate minterms.
- convert_to(target_repr: BooleanFunctionRepresentation, source_data: Any, space: Space, n_vars: int, **kwargs) ndarray[source]
Convert DNF to another representation.
- create_empty(n_vars: int, **kwargs) DNFFormula[source]
Create empty DNF (constant False).
- is_complete(data: DNFFormula) bool[source]
Check if DNF is complete.
- boofun.core.representations.dnf_form.create_dnf_from_minterms(minterms: List[int], n_vars: int) DNFFormula[source]
Create DNF from list of minterm indices.
- Parameters:
minterms – List of minterm indices where function is True
n_vars – Number of variables
- Returns:
DNF formula
- boofun.core.representations.dnf_form.minimize_dnf(dnf: DNFFormula) DNFFormula[source]
Minimize DNF using Quine-McCluskey algorithm (simplified).
- Parameters:
dnf – DNF formula to minimize
- Returns:
Minimized DNF formula